Commit a4883de3 authored by Jakob Andersen's avatar Jakob Andersen Committed by Chris Bracken

Run 'pod install' before building iOS app. (#8609)

Since iOS builds are CocoaPods enabled by default, we should make sure to run `pod install` to get pods wired up before building the app.

Also added a check to `flutter doctor` to verify CocoaPods is installed.

I'm passing FLUTTER_FRAMEWORK_DIR to the `pod install` command, so we can have the app's Podfile link in Flutter.framework as a pod instead of having to copy it over in xcode_backend.sh.
parent 68fb3e48
...@@ -211,6 +211,7 @@ String runCheckedSync(List<String> cmd, { ...@@ -211,6 +211,7 @@ String runCheckedSync(List<String> cmd, {
String workingDirectory, String workingDirectory,
bool allowReentrantFlutter: false, bool allowReentrantFlutter: false,
bool hideStdout: false, bool hideStdout: false,
Map<String, String> environment,
}) { }) {
return _runWithLoggingSync( return _runWithLoggingSync(
cmd, cmd,
...@@ -219,6 +220,7 @@ String runCheckedSync(List<String> cmd, { ...@@ -219,6 +220,7 @@ String runCheckedSync(List<String> cmd, {
hideStdout: hideStdout, hideStdout: hideStdout,
checked: true, checked: true,
noisyErrors: true, noisyErrors: true,
environment: environment,
); );
} }
...@@ -259,12 +261,13 @@ String _runWithLoggingSync(List<String> cmd, { ...@@ -259,12 +261,13 @@ String _runWithLoggingSync(List<String> cmd, {
String workingDirectory, String workingDirectory,
bool allowReentrantFlutter: false, bool allowReentrantFlutter: false,
bool hideStdout: false, bool hideStdout: false,
Map<String, String> environment,
}) { }) {
_traceCommand(cmd, workingDirectory: workingDirectory); _traceCommand(cmd, workingDirectory: workingDirectory);
final ProcessResult results = processManager.runSync( final ProcessResult results = processManager.runSync(
cmd, cmd,
workingDirectory: workingDirectory, workingDirectory: workingDirectory,
environment: _environment(allowReentrantFlutter), environment: _environment(allowReentrantFlutter, environment),
); );
printTrace('Exit code ${results.exitCode} from: ${cmd.join(' ')}'); printTrace('Exit code ${results.exitCode} from: ${cmd.join(' ')}');
......
...@@ -41,6 +41,10 @@ class IOSWorkflow extends DoctorValidator implements Workflow { ...@@ -41,6 +41,10 @@ class IOSWorkflow extends DoctorValidator implements Workflow {
bool get hasPythonSixModule => exitsHappy(<String>['python', '-c', 'import six']); bool get hasPythonSixModule => exitsHappy(<String>['python', '-c', 'import six']);
bool get hasCocoaPods => exitsHappy(<String>['pod', '--version']);
String get cocoaPodsVersionText => runSync(<String>['pod', '--version']).trim();
bool get _iosDeployIsInstalledAndMeetsVersionCheck { bool get _iosDeployIsInstalledAndMeetsVersionCheck {
if (!hasIosDeploy) if (!hasIosDeploy)
return false; return false;
...@@ -58,6 +62,7 @@ class IOSWorkflow extends DoctorValidator implements Workflow { ...@@ -58,6 +62,7 @@ class IOSWorkflow extends DoctorValidator implements Workflow {
ValidationType xcodeStatus = ValidationType.missing; ValidationType xcodeStatus = ValidationType.missing;
ValidationType pythonStatus = ValidationType.missing; ValidationType pythonStatus = ValidationType.missing;
ValidationType brewStatus = ValidationType.missing; ValidationType brewStatus = ValidationType.missing;
ValidationType podStatus = ValidationType.missing;
String xcodeVersionInfo; String xcodeVersionInfo;
if (xcode.isInstalled) { if (xcode.isInstalled) {
...@@ -160,8 +165,19 @@ class IOSWorkflow extends DoctorValidator implements Workflow { ...@@ -160,8 +165,19 @@ class IOSWorkflow extends DoctorValidator implements Workflow {
)); ));
} }
if (hasCocoaPods) {
podStatus = ValidationType.installed;
messages.add(new ValidationMessage('CocoaPods version $cocoaPodsVersionText'));
} else {
podStatus = ValidationType.missing;
messages.add(new ValidationMessage.error(
'CocoaPods not installed; this is used for iOS development.\n'
'Install by running: \'sudo gem install cocoapods\''
));
}
return new ValidationResult( return new ValidationResult(
<ValidationType>[xcodeStatus, pythonStatus, brewStatus].reduce(_mergeValidationTypes), <ValidationType>[xcodeStatus, pythonStatus, brewStatus, podStatus].reduce(_mergeValidationTypes),
messages, messages,
statusInfo: xcodeVersionInfo statusInfo: xcodeVersionInfo
); );
......
...@@ -123,8 +123,10 @@ Future<XcodeBuildResult> buildXcodeProject({ ...@@ -123,8 +123,10 @@ Future<XcodeBuildResult> buildXcodeProject({
// Before the build, all service definitions must be updated and the dylibs // 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. // copied over to a location that is suitable for Xcodebuild to find them.
final Directory appDirectory = fs.directory(app.appDirectory);
await _addServicesToBundle(appDirectory);
await _addServicesToBundle(fs.directory(app.appDirectory)); _installCocoaPods(appDirectory, flutterFrameworkDir(mode));
final List<String> commands = <String>[ final List<String> commands = <String>[
'/usr/bin/env', '/usr/bin/env',
...@@ -315,6 +317,16 @@ bool _checkXcodeVersion() { ...@@ -315,6 +317,16 @@ bool _checkXcodeVersion() {
return true; return true;
} }
void _installCocoaPods(Directory bundle, String engineDirectory) {
if (fs.file(fs.path.join(bundle.path, 'Podfile')).existsSync()) {
runCheckedSync(
<String>['pod', 'install'],
workingDirectory: bundle.path,
environment: <String, String>{'FLUTTER_FRAMEWORK_DIR': engineDirectory},
);
}
}
Future<Null> _addServicesToBundle(Directory bundle) async { Future<Null> _addServicesToBundle(Directory bundle) async {
final List<Map<String, String>> services = <Map<String, String>>[]; final List<Map<String, String>> services = <Map<String, String>>[];
printTrace("Trying to resolve native pub services."); printTrace("Trying to resolve native pub services.");
......
...@@ -12,6 +12,10 @@ import '../globals.dart'; ...@@ -12,6 +12,10 @@ import '../globals.dart';
final RegExp _settingExpr = new RegExp(r'(\w+)\s*=\s*(\S+)'); final RegExp _settingExpr = new RegExp(r'(\w+)\s*=\s*(\S+)');
final RegExp _varExpr = new RegExp(r'\$\((.*)\)'); final RegExp _varExpr = new RegExp(r'\$\((.*)\)');
String flutterFrameworkDir(BuildMode mode) {
return fs.path.normalize(fs.path.dirname(artifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, mode)));
}
void updateXcodeGeneratedProperties(String projectPath, BuildMode mode, String target) { void updateXcodeGeneratedProperties(String projectPath, BuildMode mode, String target) {
final StringBuffer localsBuffer = new StringBuffer(); final StringBuffer localsBuffer = new StringBuffer();
...@@ -34,8 +38,7 @@ void updateXcodeGeneratedProperties(String projectPath, BuildMode mode, String t ...@@ -34,8 +38,7 @@ void updateXcodeGeneratedProperties(String projectPath, BuildMode mode, String t
localsBuffer.writeln('SYMROOT=\${SOURCE_ROOT}/../${getIosBuildDirectory()}'); localsBuffer.writeln('SYMROOT=\${SOURCE_ROOT}/../${getIosBuildDirectory()}');
final String flutterFrameworkDir = fs.path.normalize(fs.path.dirname(artifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, mode))); localsBuffer.writeln('FLUTTER_FRAMEWORK_DIR=${flutterFrameworkDir(mode)}');
localsBuffer.writeln('FLUTTER_FRAMEWORK_DIR=$flutterFrameworkDir');
if (artifacts is LocalEngineArtifacts) { if (artifacts is LocalEngineArtifacts) {
final LocalEngineArtifacts localEngineArtifacts = artifacts; final LocalEngineArtifacts localEngineArtifacts = artifacts;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment