Skip to content

Commit 3820cdf

Browse files
authored
Remove Xcode environment when building swift tools in Xcode pre-action (flutter#190848)
By default, commands run within Xcode build scripts inherit the Xcode build environment. This conflicts with the `swift build` command for some reason with Xcode 27. To mitigate, we ignore the environment by prefixing with `env -i`. Fixes flutter#190846. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [AI contribution guidelines]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
1 parent 3f2a8ba commit 3820cdf

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)