Commit eedc5d9f authored by Jakob Andersen's avatar Jakob Andersen Committed by GitHub

Make pod install a long-running step. (#8999)

The very first time `pod install` is invoked, CocoaPods downloads the master spec repository, which takes quite a while. Before this change, the build appeared to have stalled. With this change, at least the spinner is moving.

Added `pod setup` to the install instructions for CocoaPods, so the spec repo is downloaded while setting up Flutter, instead of during the first build.
parent 5a101024
...@@ -182,19 +182,36 @@ Future<Process> runDetached(List<String> cmd) { ...@@ -182,19 +182,36 @@ Future<Process> runDetached(List<String> cmd) {
Future<RunResult> runAsync(List<String> cmd, { Future<RunResult> runAsync(List<String> cmd, {
String workingDirectory, String workingDirectory,
bool allowReentrantFlutter: false bool allowReentrantFlutter: false,
Map<String, String> environment
}) async { }) async {
_traceCommand(cmd, workingDirectory: workingDirectory); _traceCommand(cmd, workingDirectory: workingDirectory);
final ProcessResult results = await processManager.run( final ProcessResult results = await processManager.run(
cmd, cmd,
workingDirectory: workingDirectory, workingDirectory: workingDirectory,
environment: _environment(allowReentrantFlutter), environment: _environment(allowReentrantFlutter, environment),
); );
final RunResult runResults = new RunResult(results); final RunResult runResults = new RunResult(results);
printTrace(runResults.toString()); printTrace(runResults.toString());
return runResults; return runResults;
} }
Future<RunResult> runCheckedAsync(List<String> cmd, {
String workingDirectory,
bool allowReentrantFlutter: false,
Map<String, String> environment
}) async {
final RunResult result = await runAsync(
cmd,
workingDirectory: workingDirectory,
allowReentrantFlutter: allowReentrantFlutter,
environment: environment
);
if (result.exitCode != 0)
throw 'Exit code ${result.exitCode} from: ${cmd.join(' ')}';
return result;
}
bool exitsHappy(List<String> cli) { bool exitsHappy(List<String> cli) {
_traceCommand(cli); _traceCommand(cli);
try { try {
......
...@@ -6,7 +6,6 @@ import 'dart:async'; ...@@ -6,7 +6,6 @@ import 'dart:async';
import '../application_package.dart'; import '../application_package.dart';
import '../base/common.dart'; import '../base/common.dart';
import '../base/logger.dart';
import '../base/utils.dart'; import '../base/utils.dart';
import '../build_info.dart'; import '../build_info.dart';
import '../globals.dart'; import '../globals.dart';
...@@ -64,8 +63,7 @@ class BuildIOSCommand extends BuildSubCommand { ...@@ -64,8 +63,7 @@ class BuildIOSCommand extends BuildSubCommand {
final String logTarget = forSimulator ? 'simulator' : 'device'; final String logTarget = forSimulator ? 'simulator' : 'device';
final String typeName = artifacts.getEngineType(TargetPlatform.ios, getBuildMode()); final String typeName = artifacts.getEngineType(TargetPlatform.ios, getBuildMode());
final Status status = logger.startProgress('Building $app for $logTarget ($typeName)...', printStatus('Building $app for $logTarget ($typeName)...');
expectSlowOperation: true);
final XcodeBuildResult result = await buildXcodeProject( final XcodeBuildResult result = await buildXcodeProject(
app: app, app: app,
mode: getBuildMode(), mode: getBuildMode(),
...@@ -73,7 +71,6 @@ class BuildIOSCommand extends BuildSubCommand { ...@@ -73,7 +71,6 @@ class BuildIOSCommand extends BuildSubCommand {
buildForDevice: !forSimulator, buildForDevice: !forSimulator,
codesign: shouldCodesign codesign: shouldCodesign
); );
status.stop();
if (!result.success) { if (!result.success) {
await diagnoseXcodeBuildFailure(result); await diagnoseXcodeBuildFailure(result);
......
...@@ -185,13 +185,15 @@ class IOSWorkflow extends DoctorValidator implements Workflow { ...@@ -185,13 +185,15 @@ class IOSWorkflow extends DoctorValidator implements Workflow {
messages.add(new ValidationMessage.error( messages.add(new ValidationMessage.error(
'CocoaPods not installed. To install:\n' 'CocoaPods not installed. To install:\n'
'brew update\n' 'brew update\n'
'brew install cocoapods' 'brew install cocoapods\n'
'pod setup'
)); ));
} else { } else {
messages.add(new ValidationMessage.error( messages.add(new ValidationMessage.error(
'CocoaPods out of date ($cocoaPodsMinimumVersion is required). To upgrade:\n' 'CocoaPods out of date ($cocoaPodsMinimumVersion is required). To upgrade:\n'
'brew update\n' 'brew update\n'
'brew upgrade cocoapods' 'brew upgrade cocoapods\n'
'pod setup'
)); ));
} }
} }
......
...@@ -11,6 +11,7 @@ import '../application_package.dart'; ...@@ -11,6 +11,7 @@ import '../application_package.dart';
import '../base/context.dart'; import '../base/context.dart';
import '../base/common.dart'; import '../base/common.dart';
import '../base/file_system.dart'; import '../base/file_system.dart';
import '../base/logger.dart';
import '../base/io.dart'; import '../base/io.dart';
import '../base/platform.dart'; import '../base/platform.dart';
import '../base/process.dart'; import '../base/process.dart';
...@@ -130,7 +131,7 @@ Future<XcodeBuildResult> buildXcodeProject({ ...@@ -130,7 +131,7 @@ Future<XcodeBuildResult> buildXcodeProject({
await _addServicesToBundle(appDirectory); await _addServicesToBundle(appDirectory);
writeFlutterPluginsList(); writeFlutterPluginsList();
_runPodInstall(appDirectory, flutterFrameworkDir(mode)); await _runPodInstall(appDirectory, flutterFrameworkDir(mode));
final List<String> commands = <String>[ final List<String> commands = <String>[
'/usr/bin/env', '/usr/bin/env',
...@@ -170,11 +171,13 @@ Future<XcodeBuildResult> buildXcodeProject({ ...@@ -170,11 +171,13 @@ Future<XcodeBuildResult> buildXcodeProject({
); );
} }
final Status status = logger.startProgress('Running Xcode build...', expectSlowOperation: true);
final RunResult result = await runAsync( final RunResult result = await runAsync(
commands, commands,
workingDirectory: app.appDirectory, workingDirectory: app.appDirectory,
allowReentrantFlutter: true allowReentrantFlutter: true
); );
status.stop();
if (result.exitCode != 0) { if (result.exitCode != 0) {
printStatus('Failed to build iOS app'); printStatus('Failed to build iOS app');
...@@ -321,7 +324,7 @@ bool _checkXcodeVersion() { ...@@ -321,7 +324,7 @@ bool _checkXcodeVersion() {
return true; return true;
} }
void _runPodInstall(Directory bundle, String engineDirectory) { Future<Null> _runPodInstall(Directory bundle, String engineDirectory) async {
if (fs.file(fs.path.join(bundle.path, 'Podfile')).existsSync()) { if (fs.file(fs.path.join(bundle.path, 'Podfile')).existsSync()) {
if (!doctor.iosWorkflow.cocoaPodsInstalledAndMeetsVersionCheck) { if (!doctor.iosWorkflow.cocoaPodsInstalledAndMeetsVersionCheck) {
final String minimumVersion = doctor.iosWorkflow.cocoaPodsMinimumVersion; final String minimumVersion = doctor.iosWorkflow.cocoaPodsMinimumVersion;
...@@ -329,11 +332,13 @@ void _runPodInstall(Directory bundle, String engineDirectory) { ...@@ -329,11 +332,13 @@ void _runPodInstall(Directory bundle, String engineDirectory) {
return; return;
} }
try { try {
runCheckedSync( final Status status = logger.startProgress('Running pod install...', expectSlowOperation: true);
await runCheckedAsync(
<String>['pod', 'install'], <String>['pod', 'install'],
workingDirectory: bundle.path, workingDirectory: bundle.path,
environment: <String, String>{'FLUTTER_FRAMEWORK_DIR': engineDirectory}, environment: <String, String>{'FLUTTER_FRAMEWORK_DIR': engineDirectory},
); );
status.stop();
} catch (e) { } catch (e) {
throwToolExit('Error running pod install: $e'); throwToolExit('Error running pod install: $e');
} }
......
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