diff --git a/packages/flutter_tools/lib/src/ios/ios_workflow.dart b/packages/flutter_tools/lib/src/ios/ios_workflow.dart index dbaadf6721..ba4d2d9cf2 100644 --- a/packages/flutter_tools/lib/src/ios/ios_workflow.dart +++ b/packages/flutter_tools/lib/src/ios/ios_workflow.dart @@ -41,7 +41,7 @@ class IOSWorkflow extends DoctorValidator implements Workflow { bool get hasHomebrew => os.which('brew') != null; - bool get hasPythonSixModule => exitsHappy(['python', '-c', 'import six']); + bool get hasPythonSixModule => kPythonSix.isInstalled; bool get hasCocoaPods => exitsHappy(['pod', '--version']); @@ -124,10 +124,7 @@ class IOSWorkflow extends DoctorValidator implements Workflow { pythonStatus = ValidationType.installed; } else { pythonStatus = ValidationType.missing; - messages.add(new ValidationMessage.error( - 'Python installation missing module "six".\n' - 'Install via \'pip install six\' or \'sudo easy_install six\'.' - )); + messages.add(new ValidationMessage.error(kPythonSix.errorMessage)); } // brew installed diff --git a/packages/flutter_tools/lib/src/ios/mac.dart b/packages/flutter_tools/lib/src/ios/mac.dart index 030de20b65..adbb5ad77c 100644 --- a/packages/flutter_tools/lib/src/ios/mac.dart +++ b/packages/flutter_tools/lib/src/ios/mac.dart @@ -27,6 +27,23 @@ import 'xcodeproj.dart'; const int kXcodeRequiredVersionMajor = 7; const int kXcodeRequiredVersionMinor = 0; +// The Python `six` module is a dependency for Xcode builds, and installed by +// default, but may not be present in custom Python installs; e.g., via +// Homebrew. +const PythonModule kPythonSix = const PythonModule('six'); + +class PythonModule { + const PythonModule(this.name); + + final String name; + + bool get isInstalled => exitsHappy(['python', '-c', 'import $name']); + + String get errorMessage => + 'Missing Xcode dependency: Python module "$name".\n' + 'Install via \'pip install $name\' or \'sudo easy_install $name\'.'; +} + class Xcode { Xcode() { _eulaSigned = false; @@ -125,6 +142,11 @@ Future buildXcodeProject({ if (!_checkXcodeVersion()) return new XcodeBuildResult(success: false); + if (!kPythonSix.isInstalled) { + printError(kPythonSix.errorMessage); + return new XcodeBuildResult(success: false); + } + // Before the build, all service definitions must be updated and the dylibs // copied over to a location that is suitable for Xcodebuild to find them. final Directory appDirectory = fs.directory(app.appDirectory);