Commit b37112af authored by Chinmay Garde's avatar Chinmay Garde

Rewrite Local.xcconfig per build

In case the user changes the path of the Flutter project on disk, the Dart SDK or the Flutter repository itself, the old Xcode paths would be invalid. Now, we rewrite them when we build the project.
parent df946dd8
......@@ -565,12 +565,16 @@ String _getIOSEngineRevision(ApplicationPackage app) {
}
Future<bool> _buildIOSXcodeProject(ApplicationPackage app, { bool buildForDevice }) async {
String flutterProjectPath = Directory.current.path;
if (xcodeProjectRequiresUpdate()) {
printTrace('Initializing the Xcode project.');
if ((await setupXcodeProjectHarness()) != 0) {
if ((await setupXcodeProjectHarness(flutterProjectPath)) != 0) {
printError('Could not initialize the Xcode project.');
return false;
}
} else {
updateXcodeLocalProperties(flutterProjectPath);
}
if (!_validateEngineRevision(app))
......
......@@ -91,7 +91,7 @@ Future<bool> _inflateXcodeArchive(String directory, List<int> archiveBytes) asyn
return true;
}
void _setupXcodeProjXcconfig(String filePath) {
void updateXcodeLocalProperties(String projectPath) {
StringBuffer localsBuffer = new StringBuffer();
localsBuffer.writeln('// This is a generated file; do not edit or check into version control.');
......@@ -106,7 +106,7 @@ void _setupXcodeProjXcconfig(String filePath) {
String dartSDKPath = path.normalize(path.join(Platform.resolvedExecutable, '..', '..'));
localsBuffer.writeln('DART_SDK_PATH=$dartSDKPath');
File localsFile = new File(filePath);
File localsFile = new File(path.join(projectPath, 'ios', '.generated', 'Local.xcconfig'));
localsFile.createSync(recursive: true);
localsFile.writeAsStringSync(localsBuffer.toString());
}
......@@ -130,9 +130,9 @@ bool xcodeProjectRequiresUpdate() {
return false;
}
Future<int> setupXcodeProjectHarness() async {
Future<int> setupXcodeProjectHarness(String flutterProjectPath) async {
// Step 1: Fetch the archive from the cloud
String iosFilesPath = path.join(Directory.current.path, 'ios');
String iosFilesPath = path.join(flutterProjectPath, 'ios');
String xcodeprojPath = path.join(iosFilesPath, '.generated');
List<int> archiveBytes = await _fetchXcodeArchive();
......@@ -149,7 +149,7 @@ Future<int> setupXcodeProjectHarness() async {
}
// Step 3: Populate the Local.xcconfig with project specific paths
_setupXcodeProjXcconfig(path.join(xcodeprojPath, 'Local.xcconfig'));
updateXcodeLocalProperties(flutterProjectPath);
// Step 4: Write the REVISION file
File revisionFile = new File(path.join(xcodeprojPath, 'REVISION'));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment