Add FlutterFramework as an Xcode SwiftPM local package override#179512
Add FlutterFramework as an Xcode SwiftPM local package override#179512auto-submit[bot] merged 11 commits into
Conversation
The main purpose of this PR is to add the Flutter framework as a Swift Package dependency. As such, Xcode will now handle the copying, thinning, and codesigning of the framework and therefore the Flutter Xcode Run Scripts shouldn't. This will allow plugins to declare a dependency on the Flutter framework package and eliminate the need for the Pre-Action "prepare" script. This PR does not technically make the Flutter framework a local package override, that will be added in a follow up PR: #179512 This change includes: * Generation of the FlutterFramework swift package (this will generate a Package.swift and symlink to the Flutter framework in the artifact cache) <img width="400" height="271" alt="Screenshot 2025-12-04 at 4 54 43 PM" src="https://github.com/user-attachments/assets/6cfde6da-3698-4b76-b3b1-725f91fbf58d" /> * Adding the FlutterFramework as a dependency to the FlutterGeneratedPluginSwiftPackage (which the the Swift package the Xcode project has a dependency on) <img width="400" height="195" alt="Screenshot 2025-12-04 at 4 55 13 PM" src="https://github.com/user-attachments/assets/30fa402a-6a11-4df0-b2cd-a4a82197e50a" /> ### Change to Flutter Run Scripts Flutter currently has 3 Xcode Run Scripts: * prepare (happens in a scheme pre-action) * [PREVIOUS] Via `flutter assemble` - copies the Flutter framework from engine build cache to `BUILT_PRODUCTS_DIR` * [NEW] Same as previous except skips codesigning. This is still included to accommodate plugins that don't have a dependency declared on the Flutter framework. * build (happens in first Run Script in the Xcode build phases that happens before compiling) * [PREVIOUS] Via `flutter assemble` - copies, thins, and codesigns Flutter framework into `BUILT_PRODUCTS_DIR` * [NEW] Is skipped, Xcode now does this * embed_and_thin (happens in second Run Script in the Xcode build phases after compiling, linking, and embedding) * [PREVIOUS] Copies Flutter framework from `BUILT_PRODUCTS_DIR` to `TARGET_BUILD_DIR` * [NEW] * Validates Flutter framework in `BUILT_PRODUCTS_DIR` & `TARGET_BUILD_DIR` (which would have been put there by Xcode via SwiftPM) matches the Flutter framework in the engine cache. * If it matches, do not copy. Xcode now does this. * If it doesn't: * Call `flutter assemble` to copy the correct Flutter framework into `BUILT_PRODUCTS_DIR` * Then copy from `BUILT_PRODUCTS_DIR` to `TARGET_BUILD_DIR`. Fixes #166489. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [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]. **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 [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
There was a problem hiding this comment.
Code Review
This pull request introduces significant enhancements to Swift Package Manager integration within Flutter projects. It adds support for including FlutterFramework as an Xcode local package override and extends this functionality to include plugin overrides for example applications. The changes are well-implemented across the SwiftPackageManagerIntegrationMigration class, Xcode project templates for both iOS and macOS, and are thoroughly covered by new and updated test cases. The code demonstrates a clear understanding of Xcode project structures and Swift Package Manager mechanics, ensuring robust and correct migration behavior.
| final List<String>? packageReferences; | ||
| } | ||
|
|
||
| class _PluginRelativeToExample { |
There was a problem hiding this comment.
Optional: you could just used a record with named fields, instead of defining a type just to return two things.
There was a problem hiding this comment.
Oooh cool, I didn't know you could do named fields. Done!
| }) { | ||
| try { | ||
| final FlutterProject flutterProject = xcodeProject.parent; | ||
| if (flutterProject.directory.path.endsWith('example') && |
There was a problem hiding this comment.
This won't catch everything; it wouldn't work for the current google_maps_flutter_ios examples, for instance. I would expect that's rare enough that it's not a significant issue, but we should consider whether we can document somewhere—maybe even just as a comment in the issue this fixes—how unusual examples could be fixed manually.
We could try to make this more comprehensive by walking up several levels looking for an example directory that is in a directory with a pubspec), but I think it's probably not worth the added complexity.
There was a problem hiding this comment.
Right, this makes like a best effort. I plan to also add website docs: flutter/website#12936
| {{#withSwiftPackageManager}} | ||
| 78E0A7A72DC9AD7400C4905E /* FlutterGeneratedPluginSwiftPackage */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = FlutterGeneratedPluginSwiftPackage; path = Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage; sourceTree = "<group>"; }; | ||
| 784666492D4C4C64000A1A5F /* FlutterFramework */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = FlutterFramework; path = Flutter/ephemeral/Packages/.packages/FlutterFramework; sourceTree = "<group>"; }; | ||
| {{#withPlatformChannelPluginHook}} |
There was a problem hiding this comment.
Oops, I forgot this is the condition name we used for plugins with a plugin-style build. We'll need to rename it at some point (not directly related to this PR, mostly noting as a reminder to myself).
The main purpose of this PR is to add the Flutter framework as a Swift Package dependency. As such, Xcode will now handle the copying, thinning, and codesigning of the framework and therefore the Flutter Xcode Run Scripts shouldn't. This will allow plugins to declare a dependency on the Flutter framework package and eliminate the need for the Pre-Action "prepare" script. This PR does not technically make the Flutter framework a local package override, that will be added in a follow up PR: flutter#179512 This change includes: * Generation of the FlutterFramework swift package (this will generate a Package.swift and symlink to the Flutter framework in the artifact cache) <img width="400" height="271" alt="Screenshot 2025-12-04 at 4 54 43 PM" src="https://github.com/user-attachments/assets/6cfde6da-3698-4b76-b3b1-725f91fbf58d" /> * Adding the FlutterFramework as a dependency to the FlutterGeneratedPluginSwiftPackage (which the the Swift package the Xcode project has a dependency on) <img width="400" height="195" alt="Screenshot 2025-12-04 at 4 55 13 PM" src="https://github.com/user-attachments/assets/30fa402a-6a11-4df0-b2cd-a4a82197e50a" /> ### Change to Flutter Run Scripts Flutter currently has 3 Xcode Run Scripts: * prepare (happens in a scheme pre-action) * [PREVIOUS] Via `flutter assemble` - copies the Flutter framework from engine build cache to `BUILT_PRODUCTS_DIR` * [NEW] Same as previous except skips codesigning. This is still included to accommodate plugins that don't have a dependency declared on the Flutter framework. * build (happens in first Run Script in the Xcode build phases that happens before compiling) * [PREVIOUS] Via `flutter assemble` - copies, thins, and codesigns Flutter framework into `BUILT_PRODUCTS_DIR` * [NEW] Is skipped, Xcode now does this * embed_and_thin (happens in second Run Script in the Xcode build phases after compiling, linking, and embedding) * [PREVIOUS] Copies Flutter framework from `BUILT_PRODUCTS_DIR` to `TARGET_BUILD_DIR` * [NEW] * Validates Flutter framework in `BUILT_PRODUCTS_DIR` & `TARGET_BUILD_DIR` (which would have been put there by Xcode via SwiftPM) matches the Flutter framework in the engine cache. * If it matches, do not copy. Xcode now does this. * If it doesn't: * Call `flutter assemble` to copy the correct Flutter framework into `BUILT_PRODUCTS_DIR` * Then copy from `BUILT_PRODUCTS_DIR` to `TARGET_BUILD_DIR`. Fixes flutter#166489. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [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]. **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 [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
|
autosubmit label was removed for flutter/flutter/179512, because The base commit of the PR is older than 7 days and can not be merged. Please merge the latest changes from the main into this branch and resubmit the PR. |
Roll Flutter from 48c2475 to bfc9041eb118 (173 revisions) flutter/flutter@48c2475...bfc9041 2026-01-23 matt.kosarek@canonical.com No longer exiting the application when the RegularWindow is destroyed + resolving the window created promise after runWidget (flutter/flutter#181339) 2026-01-23 kazbek.sultanov.doc@gmail.com Remove unnecessary Material import from dialog_test.dart (flutter/flutter#181249) 2026-01-23 engine-flutter-autoroll@skia.org Roll Skia from 8e516fe6828f to db10db8bd55f (1 revision) (flutter/flutter#181379) 2026-01-23 50643541+Mairramer@users.noreply.github.com Reset TextFormField to initial value after state change (flutter/flutter#181199) 2026-01-23 engine-flutter-autoroll@skia.org Roll Dart SDK from 980b2b41d36e to e82d7ad1855e (1 revision) (flutter/flutter#181375) 2026-01-23 engine-flutter-autoroll@skia.org Roll Skia from 3e86f377d300 to 8e516fe6828f (4 revisions) (flutter/flutter#181370) 2026-01-23 kazbek.sultanov.doc@gmail.com Remove unnecessary Material import from sliver_visibility_test (flutter/flutter#181248) 2026-01-23 43635580+Lilian-C@users.noreply.github.com Add bottom navigation bar item semantics label (flutter/flutter#180577) 2026-01-23 58190796+MitchellGoodwin@users.noreply.github.com Make topGap not required for CupertinoSheetTransition (flutter/flutter#181269) 2026-01-23 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from b4cLyhuxciUC-4zCJ... to n7NohL9DPpEuPjNt9... (flutter/flutter#181365) 2026-01-23 engine-flutter-autoroll@skia.org Roll Dart SDK from 806f04638561 to 980b2b41d36e (1 revision) (flutter/flutter#181364) 2026-01-23 34871572+gmackall@users.noreply.github.com Reland hybrid views test (flutter/flutter#181336) 2026-01-23 git@reb0.org Revert DropdownMenu non-nullable breaking change (flutter/flutter#181074) 2026-01-23 dkwingsmt@users.noreply.github.com Fix leaks in `flutter_test` tests (flutter/flutter#180879) 2026-01-23 97480502+b-luk@users.noreply.github.com Re-enable fragment_shader_tests.dart 'Shader Compiler appropriately pads vec3 uniform arrays' test on Vulkan (flutter/flutter#181292) 2026-01-23 bkonyi@google.com [ Tool ] Fix `update-packages` failing due to mismatched dependencies between flutter_tools and the framework (flutter/flutter#181335) 2026-01-23 jason-simmons@users.noreply.github.com [Impeller] Make dynamically created shader metadata for runtime effects consistent with metadata for built-in shaders (flutter/flutter#181201) 2026-01-23 97480502+b-luk@users.noreply.github.com Broaden the applicability of `Color` fix_data rules from flutter/painting.dart (flutter/flutter#181093) 2026-01-23 15619084+vashworth@users.noreply.github.com Fixes macOS App.framework not being codesigned or find framework (flutter/flutter#181348) 2026-01-22 69134234+sutes-work@users.noreply.github.com Roll Fuchsia GN SDK from NAEC5tfgSl8g94nwp... to JLBh4Z9PKsjIJcqDU... (flutter/flutter#181139) 2026-01-22 engine-flutter-autoroll@skia.org Roll Dart SDK from ab4640ea82e9 to 806f04638561 (2 revisions) (flutter/flutter#181347) 2026-01-22 sokolovskyi.konstantin@gmail.com Add ExpansibleController.toggle method. (flutter/flutter#181320) 2026-01-22 42980667+srivats22@users.noreply.github.com Fixes Typo in codebase (flutter/flutter#181256) 2026-01-22 engine-flutter-autoroll@skia.org Roll Skia from 4766615bcc96 to 3e86f377d300 (3 revisions) (flutter/flutter#181346) 2026-01-22 ahmedsameha1@gmail.com Make sure that a Hero doesn't crash in 0x0 environment (flutter/flutter#180954) 2026-01-22 jason-simmons@users.noreply.github.com Reland "Fix capitalization of the path to FlutterWindowControllerTest.mm in the macOS platform build script" (flutter/flutter#181200) 2026-01-22 engine-flutter-autoroll@skia.org Roll Skia from 6e9746be8c4a to 4766615bcc96 (3 revisions) (flutter/flutter#181331) 2026-01-22 kazbek.sultanov.doc@gmail.com Fix remove material import textfield (flutter/flutter#181254) 2026-01-22 15619084+vashworth@users.noreply.github.com Add FlutterFramework as an Xcode SwiftPM local package override (flutter/flutter#179512) 2026-01-22 engine-flutter-autoroll@skia.org Roll Dart SDK from 7bd4c68b625c to ab4640ea82e9 (1 revision) (flutter/flutter#181324) 2026-01-22 engine-flutter-autoroll@skia.org Roll Packages from d80c60e to 9010299 (9 revisions) (flutter/flutter#181323) 2026-01-22 engine-flutter-autoroll@skia.org Roll Dart SDK from 2d53a77adc5d to 7bd4c68b625c (2 revisions) (flutter/flutter#181316) 2026-01-22 engine-flutter-autoroll@skia.org Roll Skia from 3f6949bc5780 to 6e9746be8c4a (2 revisions) (flutter/flutter#181311) 2026-01-22 engine-flutter-autoroll@skia.org Roll Skia from ef6efc358b4a to 3f6949bc5780 (2 revisions) (flutter/flutter#181307) 2026-01-22 engine-flutter-autoroll@skia.org Roll Dart SDK from 5d7c8faf2e41 to 2d53a77adc5d (1 revision) (flutter/flutter#181305) 2026-01-22 120639059+Enderjua@users.noreply.github.com [Material] update hourFormat to use Dart 3 switch expression (flutter/flutter#181041) 2026-01-22 146823759+brahim-guaali@users.noreply.github.com Use null-aware elements in cupertino/nav_bar.dart (flutter/flutter#181237) 2026-01-22 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from b2KIEXVAlEqImQ9VO... to b4cLyhuxciUC-4zCJ... (flutter/flutter#181297) 2026-01-22 137456488+flutter-pub-roller-bot@users.noreply.github.com Roll pub packages (flutter/flutter#181295) 2026-01-22 30870216+gaaclarke@users.noreply.github.com Enables fragment shader test for impeller (fixes mat2 on vulkan) (flutter/flutter#181013) 2026-01-21 engine-flutter-autoroll@skia.org Roll Dart SDK from 366200db1aa1 to 5d7c8faf2e41 (4 revisions) (flutter/flutter#181290) 2026-01-21 engine-flutter-autoroll@skia.org Roll Skia from b5ec89e31f59 to ef6efc358b4a (19 revisions) (flutter/flutter#181289) 2026-01-21 brackenavaron@gmail.com fix description for semantics finders (flutter/flutter#181214) 2026-01-21 ahmedsameha1@gmail.com Make sure that an Icon doesn't crash in 0x0 environment (flutter/flutter#181021) 2026-01-21 ahmedsameha1@gmail.com Make sure that a GridPaper doesn't crash in 0x0 environment (flutter/flutter#180906) 2026-01-21 magder@google.com Bring Linux coverage out of bringup (flutter/flutter#181280) ...
…ter#179512) This PR adds the FlutterFramework as an Xcode local package override by adding it as a "file" to the Xcode project. In addition, it also adds the plugin as a local package override if we detect the app is a plugin's example app. <img width="265" height="144" alt="Screenshot 2025-12-04 at 10 29 16 PM" src="https://github.com/user-attachments/assets/b822aa3c-14bd-4444-9e44-4e781a5ac11e" /> Fixes flutter#179032. Fixes flutter#172427. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [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]. **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 [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
This PR adds the FlutterFramework as an Xcode local package override by adding it as a "file" to the Xcode project. In addition, it also adds the plugin as a local package override if we detect the app is a plugin's example app.
Fixes #179032. Fixes #172427.
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot 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.