diff --git a/packages/flutter_tools/lib/src/ios/device_ios.dart b/packages/flutter_tools/lib/src/ios/device_ios.dart index eaea55d1c56..8ac8a226218 100644 --- a/packages/flutter_tools/lib/src/ios/device_ios.dart +++ b/packages/flutter_tools/lib/src/ios/device_ios.dart @@ -560,8 +560,8 @@ String _getIOSEngineRevision(ApplicationPackage app) { } Future _buildIOSXcodeProject(ApplicationPackage app, { bool buildForDevice }) async { - if (!FileSystemEntity.isDirectorySync(app.localPath)) { - printTrace('Path "${path.absolute(app.localPath)}" does not exist. Initializing the Xcode project.'); + if (xcodeProjectRequiresUpdate()) { + printTrace('Initializing the Xcode project.'); if ((await setupXcodeProjectHarness()) != 0) { printError('Could not initialize the Xcode project.'); return false; diff --git a/packages/flutter_tools/lib/src/ios/setup_xcodeproj.dart b/packages/flutter_tools/lib/src/ios/setup_xcodeproj.dart index aa0e35ccb53..10339ee5278 100644 --- a/packages/flutter_tools/lib/src/ios/setup_xcodeproj.dart +++ b/packages/flutter_tools/lib/src/ios/setup_xcodeproj.dart @@ -111,6 +111,25 @@ void _setupXcodeProjXcconfig(String filePath) { localsFile.writeAsStringSync(localsBuffer.toString()); } +bool xcodeProjectRequiresUpdate() { + File revisionFile = new File(path.join(Directory.current.path, 'ios', '.generated', 'REVISION')); + + // If the revision stamp does not exist, the Xcode project definitely requires + // an update + if (!revisionFile.existsSync()) { + printTrace("A revision stamp does not exist. The Xcode project has never been initialized."); + return true; + } + + if (revisionFile.readAsStringSync() != ArtifactStore.engineRevision) { + printTrace("The revision stamp and the Flutter engine revision differ. Project needs to be updated."); + return true; + } + + printTrace("Xcode project is up to date."); + return false; +} + Future setupXcodeProjectHarness() async { // Step 1: Fetch the archive from the cloud String iosFilesPath = path.join(Directory.current.path, 'ios');