From b4d72752bdd22667972a0819a261c4c7832afc0c Mon Sep 17 00:00:00 2001 From: Victoria Ashworth Date: Fri, 13 Jan 2023 13:41:08 -0600 Subject: [PATCH] Add Info.plist from build directory as input path to Thin Binary build phase (#118209) * Add Info.plist from build directory as input path to Thin Binary build phase * fix directive ordering * migrate benchmark, integration, and example tests --- .../ios/Runner.xcodeproj/project.pbxproj | 1 + .../ios/Runner.xcodeproj/project.pbxproj | 1 + .../ios/Runner.xcodeproj/project.pbxproj | 1 + .../ios/Runner.xcodeproj/project.pbxproj | 1 + .../ios/Runner.xcodeproj/project.pbxproj | 1 + .../ios/Runner.xcodeproj/project.pbxproj | 1 + .../ios/Runner.xcodeproj/project.pbxproj | 1 + .../ios/Runner.xcodeproj/project.pbxproj | 1 + .../ios/Runner.xcodeproj/project.pbxproj | 1 + .../ios/Runner.xcodeproj/project.pbxproj | 1 + .../ios/Runner.xcodeproj/project.pbxproj | 1 + .../ios/Runner.xcodeproj/project.pbxproj | 1 + .../ios/Runner.xcodeproj/project.pbxproj | 1 + .../ios/Runner.xcodeproj/project.pbxproj | 1 + .../ios/Runner.xcodeproj/project.pbxproj | 1 + .../ios/Runner.xcodeproj/project.pbxproj | 1 + .../ios/Runner.xcodeproj/project.pbxproj | 1 + .../ui/ios/Runner.xcodeproj/project.pbxproj | 1 + .../ios/Runner.xcodeproj/project.pbxproj | 1 + .../api/ios/Runner.xcodeproj/project.pbxproj | 1 + .../ios/Runner.xcodeproj/project.pbxproj | 1 + .../ios/Runner.xcodeproj/project.pbxproj | 1 + .../ios/Runner.xcodeproj/project.pbxproj | 1 + .../ios/Runner.xcodeproj/project.pbxproj | 1 + .../ios/Runner.xcodeproj/project.pbxproj | 1 + .../ios/Runner.xcodeproj/project.pbxproj | 1 + .../ios/Runner.xcodeproj/project.pbxproj | 1 + packages/flutter_tools/lib/src/ios/mac.dart | 2 + .../lib/src/macos/build_macos.dart | 2 + ...ary_build_phase_input_paths_migration.dart | 70 +++++++++++ .../Runner.xcodeproj/project.pbxproj.tmpl | 1 + .../Runner.xcodeproj/project.pbxproj.tmpl | 1 + .../project.pbxproj.tmpl | 1 + .../ios/ios_project_migration_test.dart | 109 ++++++++++++++++++ .../ios/Runner.xcodeproj/project.pbxproj | 1 + 35 files changed, 214 insertions(+) create mode 100644 packages/flutter_tools/lib/src/migrations/xcode_thin_binary_build_phase_input_paths_migration.dart diff --git a/dev/benchmarks/complex_layout/ios/Runner.xcodeproj/project.pbxproj b/dev/benchmarks/complex_layout/ios/Runner.xcodeproj/project.pbxproj index bb01ebd080..bc6da0527f 100644 --- a/dev/benchmarks/complex_layout/ios/Runner.xcodeproj/project.pbxproj +++ b/dev/benchmarks/complex_layout/ios/Runner.xcodeproj/project.pbxproj @@ -232,6 +232,7 @@ files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( diff --git a/dev/benchmarks/macrobenchmarks/ios/Runner.xcodeproj/project.pbxproj b/dev/benchmarks/macrobenchmarks/ios/Runner.xcodeproj/project.pbxproj index 65e883d2dd..d028eda22c 100644 --- a/dev/benchmarks/macrobenchmarks/ios/Runner.xcodeproj/project.pbxproj +++ b/dev/benchmarks/macrobenchmarks/ios/Runner.xcodeproj/project.pbxproj @@ -236,6 +236,7 @@ files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( diff --git a/dev/benchmarks/microbenchmarks/ios/Runner.xcodeproj/project.pbxproj b/dev/benchmarks/microbenchmarks/ios/Runner.xcodeproj/project.pbxproj index f9923ffcc7..3e555eae4d 100644 --- a/dev/benchmarks/microbenchmarks/ios/Runner.xcodeproj/project.pbxproj +++ b/dev/benchmarks/microbenchmarks/ios/Runner.xcodeproj/project.pbxproj @@ -187,6 +187,7 @@ files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( diff --git a/dev/benchmarks/platform_channels_benchmarks/ios/Runner.xcodeproj/project.pbxproj b/dev/benchmarks/platform_channels_benchmarks/ios/Runner.xcodeproj/project.pbxproj index 66cf645760..3530328d7f 100644 --- a/dev/benchmarks/platform_channels_benchmarks/ios/Runner.xcodeproj/project.pbxproj +++ b/dev/benchmarks/platform_channels_benchmarks/ios/Runner.xcodeproj/project.pbxproj @@ -179,6 +179,7 @@ files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( diff --git a/dev/benchmarks/platform_views_layout/ios/Runner.xcodeproj/project.pbxproj b/dev/benchmarks/platform_views_layout/ios/Runner.xcodeproj/project.pbxproj index 958b67cb47..c40eec670d 100644 --- a/dev/benchmarks/platform_views_layout/ios/Runner.xcodeproj/project.pbxproj +++ b/dev/benchmarks/platform_views_layout/ios/Runner.xcodeproj/project.pbxproj @@ -191,6 +191,7 @@ files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( diff --git a/dev/benchmarks/platform_views_layout_hybrid_composition/ios/Runner.xcodeproj/project.pbxproj b/dev/benchmarks/platform_views_layout_hybrid_composition/ios/Runner.xcodeproj/project.pbxproj index 5840bc053f..24354c0dcc 100644 --- a/dev/benchmarks/platform_views_layout_hybrid_composition/ios/Runner.xcodeproj/project.pbxproj +++ b/dev/benchmarks/platform_views_layout_hybrid_composition/ios/Runner.xcodeproj/project.pbxproj @@ -192,6 +192,7 @@ files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( diff --git a/dev/benchmarks/test_apps/stocks/ios/Runner.xcodeproj/project.pbxproj b/dev/benchmarks/test_apps/stocks/ios/Runner.xcodeproj/project.pbxproj index ca1ae70639..54f761fe67 100644 --- a/dev/benchmarks/test_apps/stocks/ios/Runner.xcodeproj/project.pbxproj +++ b/dev/benchmarks/test_apps/stocks/ios/Runner.xcodeproj/project.pbxproj @@ -194,6 +194,7 @@ files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( diff --git a/dev/integration_tests/channels/ios/Runner.xcodeproj/project.pbxproj b/dev/integration_tests/channels/ios/Runner.xcodeproj/project.pbxproj index 64382a7260..ba38c3e638 100644 --- a/dev/integration_tests/channels/ios/Runner.xcodeproj/project.pbxproj +++ b/dev/integration_tests/channels/ios/Runner.xcodeproj/project.pbxproj @@ -186,6 +186,7 @@ files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( diff --git a/dev/integration_tests/external_ui/ios/Runner.xcodeproj/project.pbxproj b/dev/integration_tests/external_ui/ios/Runner.xcodeproj/project.pbxproj index cdaa0057fe..89eb6d5532 100644 --- a/dev/integration_tests/external_ui/ios/Runner.xcodeproj/project.pbxproj +++ b/dev/integration_tests/external_ui/ios/Runner.xcodeproj/project.pbxproj @@ -177,6 +177,7 @@ files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( diff --git a/dev/integration_tests/flavors/ios/Runner.xcodeproj/project.pbxproj b/dev/integration_tests/flavors/ios/Runner.xcodeproj/project.pbxproj index decd21a953..5d5c721b32 100644 --- a/dev/integration_tests/flavors/ios/Runner.xcodeproj/project.pbxproj +++ b/dev/integration_tests/flavors/ios/Runner.xcodeproj/project.pbxproj @@ -288,6 +288,7 @@ files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( diff --git a/dev/integration_tests/flutter_gallery/ios/Runner.xcodeproj/project.pbxproj b/dev/integration_tests/flutter_gallery/ios/Runner.xcodeproj/project.pbxproj index 813453608f..ae411a9dbc 100644 --- a/dev/integration_tests/flutter_gallery/ios/Runner.xcodeproj/project.pbxproj +++ b/dev/integration_tests/flutter_gallery/ios/Runner.xcodeproj/project.pbxproj @@ -213,6 +213,7 @@ files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( diff --git a/dev/integration_tests/ios_app_with_extensions/ios/Runner.xcodeproj/project.pbxproj b/dev/integration_tests/ios_app_with_extensions/ios/Runner.xcodeproj/project.pbxproj index 4c623d7178..0cc1bb5c54 100644 --- a/dev/integration_tests/ios_app_with_extensions/ios/Runner.xcodeproj/project.pbxproj +++ b/dev/integration_tests/ios_app_with_extensions/ios/Runner.xcodeproj/project.pbxproj @@ -380,6 +380,7 @@ files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( diff --git a/dev/integration_tests/ios_platform_view_tests/ios/Runner.xcodeproj/project.pbxproj b/dev/integration_tests/ios_platform_view_tests/ios/Runner.xcodeproj/project.pbxproj index 6aa906fdbb..9b9de56a7b 100644 --- a/dev/integration_tests/ios_platform_view_tests/ios/Runner.xcodeproj/project.pbxproj +++ b/dev/integration_tests/ios_platform_view_tests/ios/Runner.xcodeproj/project.pbxproj @@ -256,6 +256,7 @@ files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( diff --git a/dev/integration_tests/non_nullable/ios/Runner.xcodeproj/project.pbxproj b/dev/integration_tests/non_nullable/ios/Runner.xcodeproj/project.pbxproj index 25f038d91b..adf2a967a9 100644 --- a/dev/integration_tests/non_nullable/ios/Runner.xcodeproj/project.pbxproj +++ b/dev/integration_tests/non_nullable/ios/Runner.xcodeproj/project.pbxproj @@ -184,6 +184,7 @@ files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( diff --git a/dev/integration_tests/platform_interaction/ios/Runner.xcodeproj/project.pbxproj b/dev/integration_tests/platform_interaction/ios/Runner.xcodeproj/project.pbxproj index f22f1b2555..069d6c8993 100644 --- a/dev/integration_tests/platform_interaction/ios/Runner.xcodeproj/project.pbxproj +++ b/dev/integration_tests/platform_interaction/ios/Runner.xcodeproj/project.pbxproj @@ -191,6 +191,7 @@ files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( diff --git a/dev/integration_tests/release_smoke_test/ios/Runner.xcodeproj/project.pbxproj b/dev/integration_tests/release_smoke_test/ios/Runner.xcodeproj/project.pbxproj index d94372e923..bbc56b1bd5 100644 --- a/dev/integration_tests/release_smoke_test/ios/Runner.xcodeproj/project.pbxproj +++ b/dev/integration_tests/release_smoke_test/ios/Runner.xcodeproj/project.pbxproj @@ -214,6 +214,7 @@ files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( diff --git a/dev/integration_tests/spell_check/ios/Runner.xcodeproj/project.pbxproj b/dev/integration_tests/spell_check/ios/Runner.xcodeproj/project.pbxproj index b686064088..9a99197175 100644 --- a/dev/integration_tests/spell_check/ios/Runner.xcodeproj/project.pbxproj +++ b/dev/integration_tests/spell_check/ios/Runner.xcodeproj/project.pbxproj @@ -186,6 +186,7 @@ files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( diff --git a/dev/integration_tests/ui/ios/Runner.xcodeproj/project.pbxproj b/dev/integration_tests/ui/ios/Runner.xcodeproj/project.pbxproj index ccd4793af9..26b3d192bb 100644 --- a/dev/integration_tests/ui/ios/Runner.xcodeproj/project.pbxproj +++ b/dev/integration_tests/ui/ios/Runner.xcodeproj/project.pbxproj @@ -210,6 +210,7 @@ files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( diff --git a/dev/manual_tests/ios/Runner.xcodeproj/project.pbxproj b/dev/manual_tests/ios/Runner.xcodeproj/project.pbxproj index e6cb90ab26..2171cdba03 100644 --- a/dev/manual_tests/ios/Runner.xcodeproj/project.pbxproj +++ b/dev/manual_tests/ios/Runner.xcodeproj/project.pbxproj @@ -176,6 +176,7 @@ files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( diff --git a/examples/api/ios/Runner.xcodeproj/project.pbxproj b/examples/api/ios/Runner.xcodeproj/project.pbxproj index 65849fe7bf..4611df2120 100644 --- a/examples/api/ios/Runner.xcodeproj/project.pbxproj +++ b/examples/api/ios/Runner.xcodeproj/project.pbxproj @@ -227,6 +227,7 @@ files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( diff --git a/examples/flutter_view/ios/Runner.xcodeproj/project.pbxproj b/examples/flutter_view/ios/Runner.xcodeproj/project.pbxproj index 6abbee8695..91c0b804e1 100644 --- a/examples/flutter_view/ios/Runner.xcodeproj/project.pbxproj +++ b/examples/flutter_view/ios/Runner.xcodeproj/project.pbxproj @@ -196,6 +196,7 @@ files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( diff --git a/examples/hello_world/ios/Runner.xcodeproj/project.pbxproj b/examples/hello_world/ios/Runner.xcodeproj/project.pbxproj index 41ff9e1217..1941d643db 100644 --- a/examples/hello_world/ios/Runner.xcodeproj/project.pbxproj +++ b/examples/hello_world/ios/Runner.xcodeproj/project.pbxproj @@ -194,6 +194,7 @@ files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( diff --git a/examples/image_list/ios/Runner.xcodeproj/project.pbxproj b/examples/image_list/ios/Runner.xcodeproj/project.pbxproj index ec59c146a2..d4d9c2ad28 100644 --- a/examples/image_list/ios/Runner.xcodeproj/project.pbxproj +++ b/examples/image_list/ios/Runner.xcodeproj/project.pbxproj @@ -187,6 +187,7 @@ files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( diff --git a/examples/layers/ios/Runner.xcodeproj/project.pbxproj b/examples/layers/ios/Runner.xcodeproj/project.pbxproj index ce1d6b245b..3c10d31c0e 100644 --- a/examples/layers/ios/Runner.xcodeproj/project.pbxproj +++ b/examples/layers/ios/Runner.xcodeproj/project.pbxproj @@ -186,6 +186,7 @@ files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( diff --git a/examples/platform_channel/ios/Runner.xcodeproj/project.pbxproj b/examples/platform_channel/ios/Runner.xcodeproj/project.pbxproj index 8572270611..e9705dcad3 100644 --- a/examples/platform_channel/ios/Runner.xcodeproj/project.pbxproj +++ b/examples/platform_channel/ios/Runner.xcodeproj/project.pbxproj @@ -194,6 +194,7 @@ files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( diff --git a/examples/platform_channel_swift/ios/Runner.xcodeproj/project.pbxproj b/examples/platform_channel_swift/ios/Runner.xcodeproj/project.pbxproj index c10d77a90f..eff1cdc219 100644 --- a/examples/platform_channel_swift/ios/Runner.xcodeproj/project.pbxproj +++ b/examples/platform_channel_swift/ios/Runner.xcodeproj/project.pbxproj @@ -192,6 +192,7 @@ files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( diff --git a/examples/platform_view/ios/Runner.xcodeproj/project.pbxproj b/examples/platform_view/ios/Runner.xcodeproj/project.pbxproj index 2a113a344e..9b5c76694f 100644 --- a/examples/platform_view/ios/Runner.xcodeproj/project.pbxproj +++ b/examples/platform_view/ios/Runner.xcodeproj/project.pbxproj @@ -195,6 +195,7 @@ files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( diff --git a/packages/flutter_tools/lib/src/ios/mac.dart b/packages/flutter_tools/lib/src/ios/mac.dart index a628fba0df..d558e3d34a 100644 --- a/packages/flutter_tools/lib/src/ios/mac.dart +++ b/packages/flutter_tools/lib/src/ios/mac.dart @@ -22,6 +22,7 @@ import '../macos/cocoapod_utils.dart'; import '../macos/xcode.dart'; import '../migrations/xcode_project_object_version_migration.dart'; import '../migrations/xcode_script_build_phase_migration.dart'; +import '../migrations/xcode_thin_binary_build_phase_input_paths_migration.dart'; import '../project.dart'; import '../reporting/reporting.dart'; import 'application_package.dart'; @@ -130,6 +131,7 @@ Future buildXcodeProject({ HostAppInfoPlistMigration(app.project, globals.logger), XcodeScriptBuildPhaseMigration(app.project, globals.logger), RemoveBitcodeMigration(app.project, globals.logger), + XcodeThinBinaryBuildPhaseInputPathsMigration(app.project, globals.logger), ]; final ProjectMigration migration = ProjectMigration(migrators); diff --git a/packages/flutter_tools/lib/src/macos/build_macos.dart b/packages/flutter_tools/lib/src/macos/build_macos.dart index ae05b8a035..182dbc8a92 100644 --- a/packages/flutter_tools/lib/src/macos/build_macos.dart +++ b/packages/flutter_tools/lib/src/macos/build_macos.dart @@ -14,6 +14,7 @@ import '../ios/xcode_build_settings.dart'; import '../ios/xcodeproj.dart'; import '../migrations/xcode_project_object_version_migration.dart'; import '../migrations/xcode_script_build_phase_migration.dart'; +import '../migrations/xcode_thin_binary_build_phase_input_paths_migration.dart'; import '../project.dart'; import 'cocoapod_utils.dart'; import 'migrations/macos_deployment_target_migration.dart'; @@ -52,6 +53,7 @@ Future buildMacOS({ MacOSDeploymentTargetMigration(flutterProject.macos, globals.logger), XcodeProjectObjectVersionMigration(flutterProject.macos, globals.logger), XcodeScriptBuildPhaseMigration(flutterProject.macos, globals.logger), + XcodeThinBinaryBuildPhaseInputPathsMigration(flutterProject.macos, globals.logger), ]; final ProjectMigration migration = ProjectMigration(migrators); diff --git a/packages/flutter_tools/lib/src/migrations/xcode_thin_binary_build_phase_input_paths_migration.dart b/packages/flutter_tools/lib/src/migrations/xcode_thin_binary_build_phase_input_paths_migration.dart new file mode 100644 index 0000000000..3f079a473c --- /dev/null +++ b/packages/flutter_tools/lib/src/migrations/xcode_thin_binary_build_phase_input_paths_migration.dart @@ -0,0 +1,70 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import '../base/file_system.dart'; +import '../base/project_migrator.dart'; +import '../xcode_project.dart'; + +// Migrate Xcode Thin Binary build phase to depend on Info.plist from build directory +// as an input file to ensure it has been created before inserting the NSBonjourServices key +// to avoid an mDNS error. +class XcodeThinBinaryBuildPhaseInputPathsMigration extends ProjectMigrator { + XcodeThinBinaryBuildPhaseInputPathsMigration(XcodeBasedProject project, super.logger) + : _xcodeProjectInfoFile = project.xcodeProjectInfoFile; + + final File _xcodeProjectInfoFile; + + @override + void migrate() { + if (!_xcodeProjectInfoFile.existsSync()) { + logger.printTrace('Xcode project not found, skipping script build phase dependency analysis removal.'); + return; + } + + final String originalProjectContents = _xcodeProjectInfoFile.readAsStringSync(); + + // Add Info.plist from build directory as an input file to Thin Binary build phase. + // Path for the Info.plist is ${TARGET_BUILD_DIR}/\${INFOPLIST_PATH} + + // Example: + // 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { + // isa = PBXShellScriptBuildPhase; + // alwaysOutOfDate = 1; + // buildActionMask = 2147483647; + // files = ( + // ); + // inputPaths = ( + // ); + + String newProjectContents = originalProjectContents; + const String thinBinaryBuildPhaseOriginal = ''' + 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); +'''; + + const String thinBinaryBuildPhaseReplacement = r''' + 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", + ); +'''; + + newProjectContents = newProjectContents.replaceAll(thinBinaryBuildPhaseOriginal, thinBinaryBuildPhaseReplacement); + if (originalProjectContents != newProjectContents) { + logger.printStatus('Adding input path to Thin Binary build phase.'); + _xcodeProjectInfoFile.writeAsStringSync(newProjectContents); + } + } +} diff --git a/packages/flutter_tools/templates/app_shared/ios-objc.tmpl/Runner.xcodeproj/project.pbxproj.tmpl b/packages/flutter_tools/templates/app_shared/ios-objc.tmpl/Runner.xcodeproj/project.pbxproj.tmpl index 243f569796..4a0a5350ba 100644 --- a/packages/flutter_tools/templates/app_shared/ios-objc.tmpl/Runner.xcodeproj/project.pbxproj.tmpl +++ b/packages/flutter_tools/templates/app_shared/ios-objc.tmpl/Runner.xcodeproj/project.pbxproj.tmpl @@ -246,6 +246,7 @@ files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( diff --git a/packages/flutter_tools/templates/app_shared/ios-swift.tmpl/Runner.xcodeproj/project.pbxproj.tmpl b/packages/flutter_tools/templates/app_shared/ios-swift.tmpl/Runner.xcodeproj/project.pbxproj.tmpl index 00206fbf62..9613c0145e 100644 --- a/packages/flutter_tools/templates/app_shared/ios-swift.tmpl/Runner.xcodeproj/project.pbxproj.tmpl +++ b/packages/flutter_tools/templates/app_shared/ios-swift.tmpl/Runner.xcodeproj/project.pbxproj.tmpl @@ -229,6 +229,7 @@ files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( diff --git a/packages/flutter_tools/templates/module/ios/host_app_ephemeral/Runner.xcodeproj.tmpl/project.pbxproj.tmpl b/packages/flutter_tools/templates/module/ios/host_app_ephemeral/Runner.xcodeproj.tmpl/project.pbxproj.tmpl index 46cfd660c7..041190948c 100644 --- a/packages/flutter_tools/templates/module/ios/host_app_ephemeral/Runner.xcodeproj.tmpl/project.pbxproj.tmpl +++ b/packages/flutter_tools/templates/module/ios/host_app_ephemeral/Runner.xcodeproj.tmpl/project.pbxproj.tmpl @@ -187,6 +187,7 @@ files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( diff --git a/packages/flutter_tools/test/general.shard/ios/ios_project_migration_test.dart b/packages/flutter_tools/test/general.shard/ios/ios_project_migration_test.dart index 6326e439d7..bf580fc993 100644 --- a/packages/flutter_tools/test/general.shard/ios/ios_project_migration_test.dart +++ b/packages/flutter_tools/test/general.shard/ios/ios_project_migration_test.dart @@ -15,6 +15,7 @@ import 'package:flutter_tools/src/ios/migrations/remove_framework_link_and_embed import 'package:flutter_tools/src/ios/migrations/xcode_build_system_migration.dart'; import 'package:flutter_tools/src/migrations/xcode_project_object_version_migration.dart'; import 'package:flutter_tools/src/migrations/xcode_script_build_phase_migration.dart'; +import 'package:flutter_tools/src/migrations/xcode_thin_binary_build_phase_input_paths_migration.dart'; import 'package:flutter_tools/src/reporting/reporting.dart'; import 'package:flutter_tools/src/xcode_project.dart'; import 'package:test/fake.dart'; @@ -1002,6 +1003,114 @@ platform :ios, '11.0' expect(testLogger.statusText, contains('Removing script build phase dependency analysis')); }); }); + + group('update Xcode Thin Binary build phase to have input path', () { + late MemoryFileSystem memoryFileSystem; + late BufferLogger testLogger; + late FakeIosProject project; + late File xcodeProjectInfoFile; + + setUp(() { + memoryFileSystem = MemoryFileSystem(); + testLogger = BufferLogger.test(); + project = FakeIosProject(); + xcodeProjectInfoFile = memoryFileSystem.file('project.pbxproj'); + project.xcodeProjectInfoFile = xcodeProjectInfoFile; + }); + + testWithoutContext('skipped if files are missing', () { + final XcodeThinBinaryBuildPhaseInputPathsMigration iosProjectMigration = XcodeThinBinaryBuildPhaseInputPathsMigration( + project, + testLogger, + ); + iosProjectMigration.migrate(); + expect(xcodeProjectInfoFile.existsSync(), isFalse); + + expect(testLogger.traceText, contains('Xcode project not found, skipping script build phase dependency analysis removal')); + expect(testLogger.statusText, isEmpty); + }); + + testWithoutContext('skipped if nothing to upgrade', () { + const String xcodeProjectInfoFileContents = r''' +/* Begin PBXShellScriptBuildPhase section */ + 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", + ); + '''; + xcodeProjectInfoFile.writeAsStringSync(xcodeProjectInfoFileContents); + + final DateTime projectLastModified = xcodeProjectInfoFile.lastModifiedSync(); + + final XcodeThinBinaryBuildPhaseInputPathsMigration iosProjectMigration = XcodeThinBinaryBuildPhaseInputPathsMigration( + project, + testLogger, + ); + iosProjectMigration.migrate(); + + expect(xcodeProjectInfoFile.lastModifiedSync(), projectLastModified); + expect(xcodeProjectInfoFile.readAsStringSync(), xcodeProjectInfoFileContents); + + expect(testLogger.statusText, isEmpty); + }); + + testWithoutContext('Thin Binary inputPaths is migrated', () { + xcodeProjectInfoFile.writeAsStringSync(r''' +/* Begin PBXShellScriptBuildPhase section */ + 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + + 9740EEB61CF901F6004384FC /* Run Script */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); +'''); + + final XcodeThinBinaryBuildPhaseInputPathsMigration iosProjectMigration = XcodeThinBinaryBuildPhaseInputPathsMigration( + project, + testLogger, + ); + iosProjectMigration.migrate(); + + expect(xcodeProjectInfoFile.readAsStringSync(), r''' +/* Begin PBXShellScriptBuildPhase section */ + 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", + ); + + 9740EEB61CF901F6004384FC /* Run Script */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); +'''); + expect(testLogger.statusText, contains('Adding input path to Thin Binary build phase.')); + }); + }); } class FakeIosProject extends Fake implements IosProject { diff --git a/packages/integration_test/example/ios/Runner.xcodeproj/project.pbxproj b/packages/integration_test/example/ios/Runner.xcodeproj/project.pbxproj index 3f9e08aa43..83ac2941b1 100644 --- a/packages/integration_test/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/integration_test/example/ios/Runner.xcodeproj/project.pbxproj @@ -333,6 +333,7 @@ files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = (