From 27293857588a5009219e634da2dde9dca4f7372f Mon Sep 17 00:00:00 2001 From: Dan Field Date: Fri, 9 Nov 2018 19:09:56 -0800 Subject: [PATCH] Make host app test actually test host app (#24131) * Make host app test actually test host app * mark updated test as flaky --- dev/devicelab/bin/tasks/module_test_ios.dart | 50 +++++++++++++++++-- dev/devicelab/manifest.yaml | 1 + .../Host.xcodeproj/project.pbxproj | 2 +- dev/integration_tests/ios_host_app/README.md | 8 +++ packages/flutter_tools/bin/xcode_backend.sh | 7 +-- .../ios/library/Flutter.tmpl/podhelper.rb | 2 +- 6 files changed, 62 insertions(+), 8 deletions(-) create mode 100644 dev/integration_tests/ios_host_app/README.md diff --git a/dev/devicelab/bin/tasks/module_test_ios.dart b/dev/devicelab/bin/tasks/module_test_ios.dart index af3cb69648..284455c6fd 100644 --- a/dev/devicelab/bin/tasks/module_test_ios.dart +++ b/dev/devicelab/bin/tasks/module_test_ios.dart @@ -14,7 +14,6 @@ import 'package:path/path.dart' as path; /// adding Flutter to an existing iOS app. Future main() async { await task(() async { - section('Create Flutter module project'); final Directory tempDir = Directory.systemTemp.createTempSync('flutter_module_test.'); @@ -23,7 +22,12 @@ Future main() async { await inDirectory(tempDir, () async { await flutter( 'create', - options: ['--org', 'io.flutter.devicelab', '--template=module', 'hello'], + options: [ + '--org', + 'io.flutter.devicelab', + '--template=module', + 'hello' + ], ); }); await prepareProvisioningCertificates(projectDir.path); @@ -127,11 +131,51 @@ Future main() async { if (!editableHostAppBuilt) { return TaskResult.failure('Failed to build editable host .app'); } + + section('Add to existing iOS app'); + + final Directory hostApp = Directory(path.join(tempDir.path, 'hello_host_app')); + mkdir(hostApp); + recursiveCopy( + Directory(path.join(flutterDirectory.path, 'dev', 'integration_tests', 'ios_host_app')), + hostApp, + ); + + await inDirectory(hostApp, () async { + await exec('pod', ['install']); + await exec( + 'xcodebuild', + [ + '-workspace', + 'Host.xcworkspace', + '-scheme', + 'Host', + '-configuration', + 'Debug', + 'CODE_SIGNING_ALLOWED=NO', + 'CODE_SIGNING_REQUIRED=NO', + 'CODE_SIGNING_IDENTITY=""', + 'EXPANDED_CODE_SIGN_IDENTITY=""', + 'CONFIGURATION_BUILD_DIR=${tempDir.path}', + ], + ); + }); + + final bool existingAppBuilt = exists(File(path.join( + tempDir.path, + 'Host.app', + 'Host', + ))); + + if (!existingAppBuilt) { + return TaskResult.failure('Failed to build existing app .app'); + } + return TaskResult.success(null); } catch (e) { return TaskResult.failure(e.toString()); } finally { - //rmTree(tempDir); + rmTree(tempDir); } }); } diff --git a/dev/devicelab/manifest.yaml b/dev/devicelab/manifest.yaml index 2a19670aaf..17567926f9 100644 --- a/dev/devicelab/manifest.yaml +++ b/dev/devicelab/manifest.yaml @@ -326,6 +326,7 @@ tasks: Checks that the module project template works and supports add2app on iOS. stage: devicelab required_agent_capabilities: ["mac/ios"] + flaky: true external_ui_integration_test_ios: description: > diff --git a/dev/integration_tests/ios_host_app/Host.xcodeproj/project.pbxproj b/dev/integration_tests/ios_host_app/Host.xcodeproj/project.pbxproj index a807ebcf39..1ed979e143 100644 --- a/dev/integration_tests/ios_host_app/Host.xcodeproj/project.pbxproj +++ b/dev/integration_tests/ios_host_app/Host.xcodeproj/project.pbxproj @@ -234,7 +234,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build\n"; + shellScript = "\"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build\n\"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed\n"; }; EDACAC7378E52BD5BBDB34D5 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; diff --git a/dev/integration_tests/ios_host_app/README.md b/dev/integration_tests/ios_host_app/README.md new file mode 100644 index 0000000000..9b71d99903 --- /dev/null +++ b/dev/integration_tests/ios_host_app/README.md @@ -0,0 +1,8 @@ +# iOS host app + +iOS host app for a Flutter module created using +``` +$ flutter create -t module hello +``` +and placed in a sibling folder to (a clone of) the host app. +Used by the `module_test_ios.dart` device lab test. diff --git a/packages/flutter_tools/bin/xcode_backend.sh b/packages/flutter_tools/bin/xcode_backend.sh index acdcf56572..8973f9ccc0 100755 --- a/packages/flutter_tools/bin/xcode_backend.sh +++ b/packages/flutter_tools/bin/xcode_backend.sh @@ -367,9 +367,10 @@ EmbedFlutterFrameworks() { # Sign the binaries we moved. local identity="${EXPANDED_CODE_SIGN_IDENTITY_NAME:-$CODE_SIGN_IDENTITY}" - - RunCommand codesign --force --verbose --sign "${identity}" -- "${xcode_frameworks_dir}/App.framework/App" - RunCommand codesign --force --verbose --sign "${identity}" -- "${xcode_frameworks_dir}/Flutter.framework/Flutter" + if (${identity} != ""); then + RunCommand codesign --force --verbose --sign "${identity}" -- "${xcode_frameworks_dir}/App.framework/App" + RunCommand codesign --force --verbose --sign "${identity}" -- "${xcode_frameworks_dir}/Flutter.framework/Flutter" + fi } # Main entry point. diff --git a/packages/flutter_tools/templates/module/ios/library/Flutter.tmpl/podhelper.rb b/packages/flutter_tools/templates/module/ios/library/Flutter.tmpl/podhelper.rb index f98153a08a..bdd3313c9b 100644 --- a/packages/flutter_tools/templates/module/ios/library/Flutter.tmpl/podhelper.rb +++ b/packages/flutter_tools/templates/module/ios/library/Flutter.tmpl/podhelper.rb @@ -68,7 +68,7 @@ post_install do |installer| config.build_settings['ENABLE_BITCODE'] = 'NO' xcconfig_path = config.base_configuration_reference.real_path File.open(xcconfig_path, 'a+') do |file| - file.puts "#include \"#{File.join(framework_dir, 'Generated.xcconfig')}\"" + file.puts "#include \"#{File.realpath(File.join(framework_dir, 'Generated.xcconfig'))}\"" end end end