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.
This commit is contained in:
Chinmay Garde
2016-02-17 12:26:00 -08:00
parent df946dd875
commit b37112af2a
2 changed files with 10 additions and 6 deletions

View File

@@ -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))

View File

@@ -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'));