Skip to content

Conversation

vashworth
Copy link
Contributor

@vashworth vashworth commented Apr 30, 2025

When iOS and macOS Flutter apps build, they use Xcode Run Scripts to call do various logic.

For iOS, the Run Scripts calls a bash file (xcode_backend.sh), which then calls a dart file (xcode_backend.dart). xcode_backend.dart then calls flutter assemble.

For macOS, the Run Scripts calls a bash file (macos_assemble.sh), which then calls flutter assemble directly.

This PR changes macos_assemble.sh to call xcode_backend.dart like it does for iOS so code can be shared between them and written in dart instead of bash.

Fixes #168033.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@github-actions github-actions bot added tool Affects the "flutter" command-line tool. See also t: labels. team-ios Owned by iOS platform team labels Apr 30, 2025
@vashworth vashworth marked this pull request as ready for review May 2, 2025 14:45
@vashworth vashworth requested a review from a team as a code owner May 2, 2025 14:45
@vashworth vashworth requested review from jmagman and bkonyi May 2, 2025 14:46
@flutter-dashboard
Copy link

Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change).

If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Changes reported for pull request #168108 at sha f34ad91

@flutter-dashboard flutter-dashboard bot added the will affect goldens Changes to golden files label May 2, 2025
@jmagman
Copy link
Member

jmagman commented May 2, 2025

This is awesome, thank you so much for doing this!

@@ -229,14 +299,61 @@ class Context {
nativeAssetsPath,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why rsync'ing would ever want delete to be false and keep around stale files, it looks intentional from #130494 but sounds like a bug.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dcharkes Do you remember if this was done intentionally?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I don't think it's intentional to leave stale files. I think it's unlikely that we'd have three builds where we have the same native asset in the first and the third build.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay I figured out why this was. It was rsyncing the entire nativeAssetsDir directory (which contained .framework sub directories) into the Frameworks directory. So if --delete was used, it would delete any frameworks that were already in the Frameworks directory. I have changed it so it rsyncs each individual .framework from the nativeAssetsDir

if (entity is Directory) {
final String? frameworkName = parseFrameworkNameFromDirectory(entity);
if (frameworkName != null) {
_codesignFramework(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/// On macOS, also codesigns the framework binaries. Codesigning occurs here rather
/// than during the Run Script build phase because the EXPANDED_CODE_SIGN_IDENTITY
/// is not passed in the build settings during the build phase for macOS.

Is this an Xcode difference between iOS and macOS?

Ideally it would be codesigned during assemble in a Target. The Target build system is very nice in that it can fingerprint the inputs and outputs and skip steps that aren't needed.

Copy link
Contributor Author

@vashworth vashworth May 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is due to the way macOS Xcode project is setup. On iOS the build phase is part of the Runner target:

Screenshot 2025-05-02 at 11 49 30 AM

However, on macOS, it's part of the Flutter Assemble target, which is an Aggregate target that does not have code signing settings:

Screenshot 2025-05-02 at 11 50 22 AM

Comment on lines +634 to +635
final String buildInputsPath = '$ephemeralDirectory/FlutterInputs.xcfilelist';
final String buildOutputsPath = '$ephemeralDirectory/FlutterOutputs.xcfilelist';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Drives me nuts how different the input/output fingerprinting is between iOS and macOS]

@jmagman jmagman requested a review from loic-sharma May 7, 2025 21:04
@@ -67,6 +67,8 @@ class Context {
return file.existsSync();
}

Directory directoryFromPath(String path) => Directory(path);
Copy link
Member

@loic-sharma loic-sharma May 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to go the extra mile, it might make sense to introduce a FileSystem type that's passed in to the Context through its constructor. The test would implement that FileSystem type & override stuffs it wants to mock. The current setup is a bit gross.

Feel free to punt this to another pull request (or never 😂) since your current changes follow the existing structure

Copy link
Member

@loic-sharma loic-sharma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent clean up. This is a huge improvement. Great work!

@vashworth vashworth requested a review from loic-sharma May 9, 2025 15:06
@vashworth
Copy link
Contributor Author

@loic-sharma Can you look it over one more time? I made some changes to pass the platform from the bash script and also to fix native assets rsync (see #168108 (comment))

case 'test_vm_service_bonjour_service':
// Exposed for integration testing only.
addVmServiceBonjourService();
}
}

/// Validates the command argument matches one of the possible commands.
/// Returns null if not.
String? validateCommand(String command) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we make this method and parseFlutterBuildMode mirror each other? Currently, validateCommand returns null on error and expects its caller print an error + exit. However, parseFlutterBuildMode prints its error and exits. I don't have a preference on which approach to take, but ideally these two methods would take the same approach :)

}
}
}
}
} else if (verbose) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd consider moving the native assets logic into a helper function since it's gotten quite big, and then switching this to be an early return

Copy link
Member

@loic-sharma loic-sharma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-LGTM!

@vashworth vashworth added the autosubmit Merge PR when tree becomes green via auto submit App label May 13, 2025
@auto-submit auto-submit bot added this pull request to the merge queue May 13, 2025
Merged via the queue into flutter:master with commit 3315c12 May 13, 2025
143 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label May 13, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 14, 2025
auto-submit bot pushed a commit to flutter/packages that referenced this pull request May 14, 2025
flutter/flutter@336a7ec...0b9f928

2025-05-14 robert.ancell@canonical.com Fix Linux Impeller support broken by incorrect deletion of stencil buffer. (flutter/flutter#168668)
2025-05-14 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from 6J81agNhuK4q255Jj... to fSvuEJgRmHxnewRJr... (flutter/flutter#168794)
2025-05-14 matanlurey@users.noreply.github.com Run `{Platform} flutter_packaging` builders on release candidates. (flutter/flutter#168762)
2025-05-14 matanlurey@users.noreply.github.com Remove `docs_deploy_beta`, fix `docs_publish`, add comments. (flutter/flutter#168754)
2025-05-14 32538273+ValentinVignal@users.noreply.github.com Add `titleAlignment` to `CheckboxListTile` and `RadioListTile`  (flutter/flutter#168666)
2025-05-14 32538273+ValentinVignal@users.noreply.github.com Remove deprecated todo about caching (flutter/flutter#168534)
2025-05-13 mohellebiabdessalem@gmail.com Replace hardcoded host and app level build.gradle paths with `AndroidProject`-level getters in `gradle_errors.dart` (flutter/flutter#167949)
2025-05-13 75997342+dogaozyagci@users.noreply.github.com Improve documentation for KeyedSubtree constructor (flutter/flutter#167198)
2025-05-13 31859944+LongCatIsLooong@users.noreply.github.com Wire up the system text scaler from `PlatformDispatcher` (flutter/flutter#159999)
2025-05-13 engine-flutter-autoroll@skia.org Roll Dart SDK from 645d04a7a964 to b3520981e0f0 (3 revisions) (flutter/flutter#168721)
2025-05-13 jhy03261997@gmail.com [a11y] Semanctis flag refactor step 3: framework part (flutter/flutter#167771)
2025-05-13 matanlurey@users.noreply.github.com Remove/replace the `team` label with `c: contributor-productivity`. (flutter/flutter#168702)
2025-05-13 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Clip search artifacts in CupertinoSliverNavigationBar searchable-to-searchable transitions (#168510)" (flutter/flutter#168775)
2025-05-13 muhatashim@google.com Use live region in error text input decorator for Android (flutter/flutter#165531)
2025-05-13 kevmoo@users.noreply.github.com [tool] Fix deprecated API calls within tool (flutter/flutter#168200)
2025-05-13 victorsanniay@gmail.com Clip search artifacts in CupertinoSliverNavigationBar searchable-to-searchable transitions (flutter/flutter#168510)
2025-05-13 47866232+chunhtai@users.noreply.github.com Fixes hero not shown when remove pages without animation (flutter/flutter#168617)
2025-05-13 rmolivares@renzo-olivares.dev [iOS] Do not hide selection handles when platform hides system context menu (flutter/flutter#168678)
2025-05-13 jessy.yameogo@gmail.com Updated execution path to silently include --start-paused and updated tests (flutter/flutter#168400)
2025-05-13 engine-flutter-autoroll@skia.org Roll Packages from 6a28ad9 to 2e166de (2 revisions) (flutter/flutter#168736)
2025-05-13 sokolovskyi.konstantin@gmail.com [web] Fix multiline input selection in Chrome. (flutter/flutter#168217)
2025-05-13 15619084+vashworth@users.noreply.github.com Call xcode_backend.dart from macos_assemble.sh (flutter/flutter#168108)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
FMorschel pushed a commit to FMorschel/packages that referenced this pull request Jun 9, 2025
…r#9251)

flutter/flutter@336a7ec...0b9f928

2025-05-14 robert.ancell@canonical.com Fix Linux Impeller support broken by incorrect deletion of stencil buffer. (flutter/flutter#168668)
2025-05-14 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from 6J81agNhuK4q255Jj... to fSvuEJgRmHxnewRJr... (flutter/flutter#168794)
2025-05-14 matanlurey@users.noreply.github.com Run `{Platform} flutter_packaging` builders on release candidates. (flutter/flutter#168762)
2025-05-14 matanlurey@users.noreply.github.com Remove `docs_deploy_beta`, fix `docs_publish`, add comments. (flutter/flutter#168754)
2025-05-14 32538273+ValentinVignal@users.noreply.github.com Add `titleAlignment` to `CheckboxListTile` and `RadioListTile`  (flutter/flutter#168666)
2025-05-14 32538273+ValentinVignal@users.noreply.github.com Remove deprecated todo about caching (flutter/flutter#168534)
2025-05-13 mohellebiabdessalem@gmail.com Replace hardcoded host and app level build.gradle paths with `AndroidProject`-level getters in `gradle_errors.dart` (flutter/flutter#167949)
2025-05-13 75997342+dogaozyagci@users.noreply.github.com Improve documentation for KeyedSubtree constructor (flutter/flutter#167198)
2025-05-13 31859944+LongCatIsLooong@users.noreply.github.com Wire up the system text scaler from `PlatformDispatcher` (flutter/flutter#159999)
2025-05-13 engine-flutter-autoroll@skia.org Roll Dart SDK from 645d04a7a964 to b3520981e0f0 (3 revisions) (flutter/flutter#168721)
2025-05-13 jhy03261997@gmail.com [a11y] Semanctis flag refactor step 3: framework part (flutter/flutter#167771)
2025-05-13 matanlurey@users.noreply.github.com Remove/replace the `team` label with `c: contributor-productivity`. (flutter/flutter#168702)
2025-05-13 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Clip search artifacts in CupertinoSliverNavigationBar searchable-to-searchable transitions (#168510)" (flutter/flutter#168775)
2025-05-13 muhatashim@google.com Use live region in error text input decorator for Android (flutter/flutter#165531)
2025-05-13 kevmoo@users.noreply.github.com [tool] Fix deprecated API calls within tool (flutter/flutter#168200)
2025-05-13 victorsanniay@gmail.com Clip search artifacts in CupertinoSliverNavigationBar searchable-to-searchable transitions (flutter/flutter#168510)
2025-05-13 47866232+chunhtai@users.noreply.github.com Fixes hero not shown when remove pages without animation (flutter/flutter#168617)
2025-05-13 rmolivares@renzo-olivares.dev [iOS] Do not hide selection handles when platform hides system context menu (flutter/flutter#168678)
2025-05-13 jessy.yameogo@gmail.com Updated execution path to silently include --start-paused and updated tests (flutter/flutter#168400)
2025-05-13 engine-flutter-autoroll@skia.org Roll Packages from 6a28ad9 to 2e166de (2 revisions) (flutter/flutter#168736)
2025-05-13 sokolovskyi.konstantin@gmail.com [web] Fix multiline input selection in Chrome. (flutter/flutter#168217)
2025-05-13 15619084+vashworth@users.noreply.github.com Call xcode_backend.dart from macos_assemble.sh (flutter/flutter#168108)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Ortes pushed a commit to Ortes/packages that referenced this pull request Jun 25, 2025
…r#9251)

flutter/flutter@336a7ec...0b9f928

2025-05-14 robert.ancell@canonical.com Fix Linux Impeller support broken by incorrect deletion of stencil buffer. (flutter/flutter#168668)
2025-05-14 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from 6J81agNhuK4q255Jj... to fSvuEJgRmHxnewRJr... (flutter/flutter#168794)
2025-05-14 matanlurey@users.noreply.github.com Run `{Platform} flutter_packaging` builders on release candidates. (flutter/flutter#168762)
2025-05-14 matanlurey@users.noreply.github.com Remove `docs_deploy_beta`, fix `docs_publish`, add comments. (flutter/flutter#168754)
2025-05-14 32538273+ValentinVignal@users.noreply.github.com Add `titleAlignment` to `CheckboxListTile` and `RadioListTile`  (flutter/flutter#168666)
2025-05-14 32538273+ValentinVignal@users.noreply.github.com Remove deprecated todo about caching (flutter/flutter#168534)
2025-05-13 mohellebiabdessalem@gmail.com Replace hardcoded host and app level build.gradle paths with `AndroidProject`-level getters in `gradle_errors.dart` (flutter/flutter#167949)
2025-05-13 75997342+dogaozyagci@users.noreply.github.com Improve documentation for KeyedSubtree constructor (flutter/flutter#167198)
2025-05-13 31859944+LongCatIsLooong@users.noreply.github.com Wire up the system text scaler from `PlatformDispatcher` (flutter/flutter#159999)
2025-05-13 engine-flutter-autoroll@skia.org Roll Dart SDK from 645d04a7a964 to b3520981e0f0 (3 revisions) (flutter/flutter#168721)
2025-05-13 jhy03261997@gmail.com [a11y] Semanctis flag refactor step 3: framework part (flutter/flutter#167771)
2025-05-13 matanlurey@users.noreply.github.com Remove/replace the `team` label with `c: contributor-productivity`. (flutter/flutter#168702)
2025-05-13 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Clip search artifacts in CupertinoSliverNavigationBar searchable-to-searchable transitions (#168510)" (flutter/flutter#168775)
2025-05-13 muhatashim@google.com Use live region in error text input decorator for Android (flutter/flutter#165531)
2025-05-13 kevmoo@users.noreply.github.com [tool] Fix deprecated API calls within tool (flutter/flutter#168200)
2025-05-13 victorsanniay@gmail.com Clip search artifacts in CupertinoSliverNavigationBar searchable-to-searchable transitions (flutter/flutter#168510)
2025-05-13 47866232+chunhtai@users.noreply.github.com Fixes hero not shown when remove pages without animation (flutter/flutter#168617)
2025-05-13 rmolivares@renzo-olivares.dev [iOS] Do not hide selection handles when platform hides system context menu (flutter/flutter#168678)
2025-05-13 jessy.yameogo@gmail.com Updated execution path to silently include --start-paused and updated tests (flutter/flutter#168400)
2025-05-13 engine-flutter-autoroll@skia.org Roll Packages from 6a28ad9 to 2e166de (2 revisions) (flutter/flutter#168736)
2025-05-13 sokolovskyi.konstantin@gmail.com [web] Fix multiline input selection in Chrome. (flutter/flutter#168217)
2025-05-13 15619084+vashworth@users.noreply.github.com Call xcode_backend.dart from macos_assemble.sh (flutter/flutter#168108)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 15, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 15, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-ios Owned by iOS platform team tool Affects the "flutter" command-line tool. See also t: labels. will affect goldens Changes to golden files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Call xcode_backend.dart from macos_assemble.sh
4 participants