From 91e6b21ea63526dfa21d12118fc88d7834d00149 Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Mon, 25 Jan 2016 12:21:13 -0800 Subject: [PATCH] Improve error messages for iOS workflow We now check that you've got an "ios" directory and that you have the proper version of Xcode. --- .../flutter_tools/lib/src/ios/device_ios.dart | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/packages/flutter_tools/lib/src/ios/device_ios.dart b/packages/flutter_tools/lib/src/ios/device_ios.dart index 34aadbe0a3..d23e665596 100644 --- a/packages/flutter_tools/lib/src/ios/device_ios.dart +++ b/packages/flutter_tools/lib/src/ios/device_ios.dart @@ -509,7 +509,35 @@ class _IOSSimulatorInfo { _IOSSimulatorInfo(this.id, this.name); } +final RegExp _xcodeVersionRegExp = new RegExp(r'Xcode (\d+)\..*'); +final String _xcodeRequirement = 'Xcode 7.0 or greater is required to develop for iOS.'; + +bool _checkXcodeVersion() { + if (!Platform.isMacOS) + return false; + try { + String version = runCheckedSync(['xcodebuild', '-version']); + Match match = _xcodeVersionRegExp.firstMatch(version); + if (int.parse(match[1]) < 7) { + logging.severe('Found "${match[0]}". $_xcodeRequirement'); + return false; + } + } catch (e) { + logging.severe('Cannot find "xcodebuid". $_xcodeRequirement'); + return false; + } + return true; +} + Future _buildIOSXcodeProject(ApplicationPackage app, bool isDevice) async { + if (!FileSystemEntity.isDirectorySync(app.localPath)) { + logging.severe('Path "${path.absolute(app.localPath)}" does not exist.\nDid you run `flutter ios --init`?'); + return false; + } + + if (!_checkXcodeVersion()) + return false; + List command = [ '/usr/bin/env', 'xcrun', 'xcodebuild', '-target', 'Runner', '-configuration', 'Release' ];