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.
diff --git a/packages/flutter_tools/lib/src/ios/device_ios.dart b/packages/flutter_tools/lib/src/ios/device_ios.dart index b6a667c..83d4695 100644 --- a/packages/flutter_tools/lib/src/ios/device_ios.dart +++ b/packages/flutter_tools/lib/src/ios/device_ios.dart
@@ -565,12 +565,16 @@ } 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))
diff --git a/packages/flutter_tools/lib/src/ios/setup_xcodeproj.dart b/packages/flutter_tools/lib/src/ios/setup_xcodeproj.dart index 704c4e6..7c98bbc 100644 --- a/packages/flutter_tools/lib/src/ios/setup_xcodeproj.dart +++ b/packages/flutter_tools/lib/src/ios/setup_xcodeproj.dart
@@ -91,7 +91,7 @@ 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 @@ 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 @@ 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 @@ } // 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'));