From 975156e91c227c0c6636259c17f5800082d654a1 Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Fri, 2 Aug 2019 13:01:25 -0700 Subject: [PATCH] If xcode_backend.sh script fails or substitute variables are missing, fail the host Xcode build (#37449) --- dev/devicelab/bin/tasks/module_test_ios.dart | 27 +++++++++++++++++++ .../ios_add2app.xcodeproj/project.pbxproj | 4 +-- .../library/Flutter.tmpl/podhelper.rb.tmpl | 2 +- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/dev/devicelab/bin/tasks/module_test_ios.dart b/dev/devicelab/bin/tasks/module_test_ios.dart index 0a976228ef..b01129e7a8 100644 --- a/dev/devicelab/bin/tasks/module_test_ios.dart +++ b/dev/devicelab/bin/tasks/module_test_ios.dart @@ -276,6 +276,33 @@ Future main() async { ); } + section('Fail building existing iOS app if flutter script fails'); + int xcodebuildExitCode = 0; + await inDirectory(hostApp, () async { + xcodebuildExitCode = await exec( + 'xcodebuild', + [ + '-workspace', + 'Host.xcworkspace', + '-scheme', + 'Host', + '-configuration', + 'Debug', + 'ARCHS=i386', // i386 is not supported in Debug mode. + 'CODE_SIGNING_ALLOWED=NO', + 'CODE_SIGNING_REQUIRED=NO', + 'CODE_SIGN_IDENTITY=-', + 'EXPANDED_CODE_SIGN_IDENTITY=-', + 'CONFIGURATION_BUILD_DIR=${tempDir.path}', + ], + canFail: true + ); + }); + + if (xcodebuildExitCode != 65) { // 65 returned on PhaseScriptExecution failure. + return TaskResult.failure('Host app build succeeded though flutter script failed'); + } + return TaskResult.success(null); } catch (e) { return TaskResult.failure(e.toString()); diff --git a/dev/integration_tests/ios_add2app/ios_add2app.xcodeproj/project.pbxproj b/dev/integration_tests/ios_add2app/ios_add2app.xcodeproj/project.pbxproj index cc75d3407b..40bddef14b 100644 --- a/dev/integration_tests/ios_add2app/ios_add2app.xcodeproj/project.pbxproj +++ b/dev/integration_tests/ios_add2app/ios_add2app.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 50; + objectVersion = 51; objects = { /* Begin PBXBuildFile section */ @@ -338,7 +338,7 @@ name = "[CP-User] Run Flutter Build Script"; runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "source \"${SRCROOT}/flutterapp/.ios/Flutter/flutter_export_environment.sh\"\n\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/xcode_backend.sh build"; + shellScript = "set -e\nset -u\nsource \"${SRCROOT}/flutterapp/.ios/Flutter/flutter_export_environment.sh\"\n\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/xcode_backend.sh build\n"; }; DE5CDCD8B3565EAB9F38F455 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; diff --git a/packages/flutter_tools/templates/module/ios/library/Flutter.tmpl/podhelper.rb.tmpl b/packages/flutter_tools/templates/module/ios/library/Flutter.tmpl/podhelper.rb.tmpl index 40af77fbc4..fb48b0ca3a 100644 --- a/packages/flutter_tools/templates/module/ios/library/Flutter.tmpl/podhelper.rb.tmpl +++ b/packages/flutter_tools/templates/module/ios/library/Flutter.tmpl/podhelper.rb.tmpl @@ -89,7 +89,7 @@ def install_flutter_application_pod(flutter_application_path) flutter_export_environment_path = File.join('${SRCROOT}', relative, 'flutter_export_environment.sh'); script_phase :name => 'Run Flutter Build Script', - :script => "source \"#{flutter_export_environment_path}\"\n\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/xcode_backend.sh build", + :script => "set -e\nset -u\nsource \"#{flutter_export_environment_path}\"\n\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/xcode_backend.sh build", :input_files => [ File.join('${SRCROOT}', flutter_application_path, '.metadata'), File.join('${SRCROOT}', relative, 'App.framework', 'App'),