Skip to content

Commit da8023b

Browse files
[CP-beta]Remove Xcode environment when building swift tools in Xcode pre-action (#191585)
This pull request is created by [automatic cherry pick workflow](https://github.com/flutter/flutter/blob/main/docs/releases/Flutter-Cherrypick-Process.md#automatically-creates-a-cherry-pick-request) Please fill in the form below, and a flutter domain expert will evaluate this cherry pick request. ### Issue Link: What is the link to the issue this cherry-pick is addressing? #190846 ### Impact Description: What is the impact (ex. visual jank on Samsung phones, app crash, cannot ship an iOS app)? Does it impact development (ex. flutter doctor crashes when Android Studio is installed), or the shipping of production apps (the app crashes on launch). This information is for domain experts and release engineers to understand the consequences of saying yes or no to the cherry pick. When integrating Flutter into a native iOS app (add-to-app) using SwiftPM, the build may fail due to ### Changelog Description: Explain this cherry pick: * In one line that is accessible to most Flutter developers. * That describes the state prior to the fix. * That includes which platforms are impacted. See [best practices](https://github.com/flutter/flutter/blob/main/docs/releases/Hotfix-Documentation-Best-Practices.md) for examples. < Replace with changelog description here > [flutter/190846] When building an existing native iOS app that's integrated with Flutter using SwiftPM on Xcode 27, it may fail to build Flutter's swift packages. ### Workaround: Is there a workaround for this issue? No ### Risk: What is the risk level of this cherry-pick? ### Test Coverage: Are you confident that your fix is well-tested by automated tests? ### Validation Steps: What are the steps to validate that this fix works? Run packages/flutter_tools/test/integration.shard/swift_package_manager_add2app_test.dart with Xcode 27
1 parent 85f14e0 commit da8023b

2 files changed

Lines changed: 18 additions & 13 deletions

File tree

‎packages/flutter_tools/templates/add_to_app/darwin/Scripts/flutter_integration.sh.tmpl‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ FLUTTER_TOOL_BUILD_MODE="release"
2828

2929
buildTool() {
3030
cd "$FLUTTER_NATIVE_TOOLS_PACKAGE_PATH" || exit 1
31-
xcrun --sdk macosx swift package clean --build-path "$FLUTTER_TOOL_BUILD_PATH"
32-
xcrun --sdk macosx swift build --product $FLUTTER_TOOL --build-path "$FLUTTER_TOOL_BUILD_PATH" -c $FLUTTER_TOOL_BUILD_MODE --disable-sandbox
31+
env -i PATH="$PATH" DEVELOPER_DIR="${DEVELOPER_DIR:-}" xcrun --sdk macosx swift package clean --build-path "$FLUTTER_TOOL_BUILD_PATH"
32+
env -i PATH="$PATH" DEVELOPER_DIR="${DEVELOPER_DIR:-}" xcrun --sdk macosx swift build --product $FLUTTER_TOOL --build-path "$FLUTTER_TOOL_BUILD_PATH" -c $FLUTTER_TOOL_BUILD_MODE --disable-sandbox
3333
}
3434

3535
# Use prebuilt tool if possible, otherwise re-build it for next time

‎packages/flutter_tools/test/integration.shard/swift_package_manager_add2app_test.dart‎

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,10 @@ void main() {
200200
],
201201
codesign: codesign,
202202
expectedOutput: [
203-
"Build of product 'flutter-prebuild-tool' complete!",
203+
RegExp(r'Gatekeeper check failed.*\.build\/prebuild\/release\/flutter-prebuild-tool'),
204+
RegExp(r'Gatekeeper check failed.*\.build\/assemble\/release\/flutter-assemble-tool'),
205+
RegExp(r'Build(?: of product .*)? complete!'),
204206
'FlutterPluginRegistrant symlink updated to ./Release',
205-
"Build of product 'flutter-assemble-tool' complete!",
206207
'flutter --verbose assemble',
207208
'release_unpack_${targetPlatform.name.toLowerCase()}: Starting',
208209
],
@@ -225,8 +226,9 @@ void main() {
225226
'Verification complete.',
226227
],
227228
unexpectedOutput: [
228-
"Build of product 'flutter-prebuild-tool' complete!",
229-
"Build of product 'flutter-assemble-tool' complete!",
229+
RegExp(r'Gatekeeper check failed.*\.build\/prebuild\/release\/flutter-prebuild-tool'),
230+
RegExp(r'Gatekeeper check failed.*\.build\/assemble\/release\/flutter-assemble-tool'),
231+
RegExp(r'Build(?: of product .*)? complete!'),
230232
'flutter --verbose assemble',
231233
'note: Transfer starting',
232234
],
@@ -255,8 +257,9 @@ void main() {
255257
'warning: Alternatively, you can remove FLUTTER_APPLICATION_PATH from your build settings to dismiss this warning.',
256258
],
257259
unexpectedOutput: [
258-
"Build of product 'flutter-prebuild-tool' complete!",
259-
"Build of product 'flutter-assemble-tool' complete!",
260+
RegExp(r'Gatekeeper check failed.*\.build\/prebuild\/release\/flutter-prebuild-tool'),
261+
RegExp(r'Gatekeeper check failed.*\.build\/assemble\/release\/flutter-assemble-tool'),
262+
RegExp(r'Build(?: of product .*)? complete!'),
260263
'flutter --verbose assemble',
261264
'note: Transfer starting',
262265
],
@@ -276,8 +279,9 @@ void main() {
276279
expectedOutput: ['Verification complete.'],
277280
unexpectedOutput: [
278281
'FlutterPluginRegistrant symlink updated to ./Release',
279-
"Build of product 'flutter-prebuild-tool' complete!",
280-
"Build of product 'flutter-assemble-tool' complete!",
282+
RegExp(r'Gatekeeper check failed.*\.build\/prebuild\/release\/flutter-prebuild-tool'),
283+
RegExp(r'Gatekeeper check failed.*\.build\/assemble\/release\/flutter-assemble-tool'),
284+
RegExp(r'Build(?: of product .*)? complete!'),
281285
'flutter --verbose assemble',
282286
'note: Transfer starting',
283287
],
@@ -401,7 +405,8 @@ void main() {
401405
'FLUTTER_APPLICATION_PATH=\$SRCROOT/../$appName',
402406
],
403407
expectedOutput: [
404-
"Build of product 'flutter-assemble-tool' complete!",
408+
RegExp(r'Gatekeeper check failed.*\.build\/assemble\/release\/flutter-assemble-tool'),
409+
RegExp(r'Build(?: of product .*)? complete!'),
405410
'FlutterPluginRegistrant symlink updated to ./Release',
406411
'flutter --verbose assemble',
407412
'release_unpack_${targetPlatform.name.toLowerCase()}: Starting',
@@ -452,8 +457,8 @@ Future<String> _buildNativeProject({
452457
required FlutterDarwinPlatform platform,
453458
required List<String> buildSettings,
454459
bool expectFailure = false,
455-
List<String> expectedOutput = const [],
456-
List<String> unexpectedOutput = const [],
460+
List<Pattern> expectedOutput = const [],
461+
List<Pattern> unexpectedOutput = const [],
457462
required bool codesign,
458463
}) async {
459464
final Map<String, String> environment = Platform.environment;

0 commit comments

Comments
 (0)