Repository navigation
Add Flutter as a Swift Package dependency - #178931
Conversation
| final String? sdkRoot = environment['SDKROOT']?.toLowerCase(); | ||
| if (sdkRoot == null || !sdkRoot.contains('iphone')) { | ||
| return null; | ||
| } | ||
| final bool simulatorSDK = sdkRoot.contains('simulator'); |
There was a problem hiding this comment.
This is mimicking:
flutter/packages/flutter_tools/lib/src/macos/xcode.dart
Lines 285 to 293 in f63cf73
| for (final FileSystemEntity entity in xcframework.listSync()) { | ||
| final String platformBaseName = Uri.parse(entity.path).pathSegments.last; | ||
| if (entity is Directory && platformBaseName.startsWith('ios-')) { | ||
| final bool isSimulatorDirectory = platformBaseName.endsWith('-simulator'); | ||
| if (simulatorSDK == isSimulatorDirectory) { | ||
| return File('${entity.path}/${platform.infoPlistPath}'); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
This is mimicking:
flutter/packages/flutter_tools/lib/src/artifacts.dart
Lines 954 to 966 in f63cf73
| for (final FileSystemEntity entity in xcframework.listSync()) { | ||
| final String platformBaseName = Uri.parse(entity.path).pathSegments.last; | ||
| if (entity is Directory && platformBaseName.startsWith('macos-')) { | ||
| return File('${entity.path}/${platform.infoPlistPath}'); | ||
| } | ||
| } |
There was a problem hiding this comment.
This is mimicking:
flutter/packages/flutter_tools/lib/src/artifacts.dart
Lines 1026 to 1033 in f63cf73
stuartmorgan-g
left a comment
There was a problem hiding this comment.
Minor comments, but LGTM. The large caveat is that I have limited familiarity with this part of the code, so am unlikely to notice subtle implementation mistakes, but the structure makes sense to me and matches my understanding of the design doc, and the tests look thorough.
|
@vashworth is this ready to merge? |
This PR creates a FlutterFramework swift package with no real content. This is a placeholder so that plugins may add a dependency on the FlutterFramework in their Package.swift before #178931 lands in stable. See go/swiftpm-flutter-release. Impacted Users: Flutter iOS with SwiftPM feature flag enabled Impact Description: Allows plugins to add a dependency on the FlutterFramework in their Package.swift. Workaround: See Problem 2 alternatives in [go/swiftpm-flutter-release](http://goto.google.com/swiftpm-flutter-release) Risk: This PR by itself is low risk. It just generates a couple files in an ephemeral directory. It only is actually used if a plugin adds a dependency on it in it's Package.swift. If a plugin does this, it's still low risk since it's basically just an empty Swift package. It's also behind a feature flag (`flutter config --enable-swift-package-manager`), which can be disabled. Test Coverage: Yes Validation Steps: - `flutter config --enable-swift-package-manager` - `flutter create my_plugin && cd my_plugin/example` - Add `FlutterFramework` to Package.swift (see [example](https://github.com/flutter/flutter/blob/master/packages/integration_test/ios/integration_test/Package.swift#L15-L21)) - `flutter build ios` **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.
This PR keeps the FlutterFramework swift package introduced in #178931, but removes the Flutter.xcframework as a dependency, essentially making it empty. As such, it also restores the build scripts to copy and codesign the framework instead of letting Xcode do it. This is a temporary solution while we decide a long-term strategy: [go/flutter-ios-privacy-impacting-sdks-codesign-requirement](http://goto.google.com/flutter-ios-privacy-impacting-sdks-codesign-requirement) Fixes #181630. ## 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 keeps the FlutterFramework swift package introduced in flutter#178931, but removes the Flutter.xcframework as a dependency, essentially making it empty. As such, it also restores the build scripts to copy and codesign the framework instead of letting Xcode do it. This is a temporary solution while we decide a long-term strategy: [go/flutter-ios-privacy-impacting-sdks-codesign-requirement](http://goto.google.com/flutter-ios-privacy-impacting-sdks-codesign-requirement) Fixes flutter#181630. ## 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 keeps the FlutterFramework swift package introduced in flutter#178931, but removes the Flutter.xcframework as a dependency, essentially making it empty. As such, it also restores the build scripts to copy and codesign the framework instead of letting Xcode do it. This is a temporary solution while we decide a long-term strategy: [go/flutter-ios-privacy-impacting-sdks-codesign-requirement](http://goto.google.com/flutter-ios-privacy-impacting-sdks-codesign-requirement) Fixes flutter#181630. ## 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 keeps the FlutterFramework swift package introduced in flutter#178931, but removes the Flutter.xcframework as a dependency, essentially making it empty. As such, it also restores the build scripts to copy and codesign the framework instead of letting Xcode do it. This is a temporary solution while we decide a long-term strategy: [go/flutter-ios-privacy-impacting-sdks-codesign-requirement](http://goto.google.com/flutter-ios-privacy-impacting-sdks-codesign-requirement) Fixes flutter#181630. ## 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 creates a FlutterFramework swift package with no real content. This is a placeholder so that plugins may add a dependency on the FlutterFramework in their Package.swift before flutter#178931 lands in stable. See go/swiftpm-flutter-release. Impacted Users: Flutter iOS with SwiftPM feature flag enabled Impact Description: Allows plugins to add a dependency on the FlutterFramework in their Package.swift. Workaround: See Problem 2 alternatives in [go/swiftpm-flutter-release](http://goto.google.com/swiftpm-flutter-release) Risk: This PR by itself is low risk. It just generates a couple files in an ephemeral directory. It only is actually used if a plugin adds a dependency on it in it's Package.swift. If a plugin does this, it's still low risk since it's basically just an empty Swift package. It's also behind a feature flag (`flutter config --enable-swift-package-manager`), which can be disabled. Test Coverage: Yes Validation Steps: - `flutter config --enable-swift-package-manager` - `flutter create my_plugin && cd my_plugin/example` - Add `FlutterFramework` to Package.swift (see [example](https://github.com/flutter/flutter/blob/master/packages/integration_test/ios/integration_test/Package.swift#L15-L21)) - `flutter build ios` **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.
This PR keeps the FlutterFramework swift package introduced in flutter/flutter#178931, but removes the Flutter.xcframework as a dependency, essentially making it empty. As such, it also restores the build scripts to copy and codesign the framework instead of letting Xcode do it. This is a temporary solution while we decide a long-term strategy: [go/flutter-ios-privacy-impacting-sdks-codesign-requirement](http://goto.google.com/flutter-ios-privacy-impacting-sdks-codesign-requirement) Fixes flutter/flutter#181630. ## 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
Flutter does not require a plugin's Package.swift to depend on the
FlutterFramework SwiftPM wrapper: flutter_tools only emits a warning
(validatePluginSupportsSwiftPackageManager in
darwin_dependency_management.dart) when it's missing, and
xcode_backend.dart keeps the legacy embed/codesign run-script path
("to accommodate plugins that don't have a dependency declared on the
Flutter framework") for exactly this case. oidc_ios 0.8.0+3 itself
shipped with an empty Package.swift dependencies list and compiled
`import Flutter` fine, proving the dependency was never load-bearing.
The FlutterFramework mechanism also doesn't exist before Flutter
3.44.0 (flutter/flutter#178931), so the floor this previously raised
to Flutter >=3.41.0 / Dart ^3.11.0 was both unnecessary and wrong -
and it broke the 0.8.x release branch's CI, which still pins Flutter
3.35.4 in .github/actions/flutter_base.
Drop the FlutterFramework dependency, restore the original SDK floor
(sdk >=3.5.0 <4.0.0, flutter >=3.22.0) from the 0.8.0+3 tag, and
revert the test file reformat that the floor bump had required. The
Package.swift relocation, Sources/ layout, and podspec path fix from
the original backport are kept, since those are the actual fix for
Flutter not finding the plugin's SwiftPM manifest.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_0126i8ymDVXbifp6LrbCiyQL
Flutter does not require a plugin's Package.swift to depend on the
FlutterFramework SwiftPM wrapper: flutter_tools only emits a warning
(validatePluginSupportsSwiftPackageManager in
darwin_dependency_management.dart) when it's missing, and
xcode_backend.dart keeps the legacy embed/codesign run-script path
("to accommodate plugins that don't have a dependency declared on the
Flutter framework") for exactly this case. oidc_macos 0.8.0+3 itself
shipped with an empty Package.swift dependencies list and compiled
`import FlutterMacOS` fine, proving the dependency was never
load-bearing.
The FlutterFramework mechanism also doesn't exist before Flutter
3.44.0 (flutter/flutter#178931), so the floor this previously raised
to Flutter >=3.41.0 / Dart ^3.11.0 was both unnecessary and wrong -
and it broke the 0.8.x release branch's CI, which still pins Flutter
3.35.4 in .github/actions/flutter_base.
Drop the FlutterFramework dependency, restore the original SDK floor
(sdk >=3.5.0 <4.0.0, flutter >=3.22.0) from the 0.8.0+3 tag, and
revert the test file reformat that the floor bump had required. The
Package.swift relocation, Sources/ layout, and podspec path fix from
the original backport are kept, since those are the actual fix for
Flutter not finding the plugin's SwiftPM manifest.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_0126i8ymDVXbifp6LrbCiyQL
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:
Change to Flutter Run Scripts
Flutter currently has 3 Xcode Run Scripts:
flutter assemble- copies the Flutter framework from engine build cache toBUILT_PRODUCTS_DIRflutter assemble- copies, thins, and codesigns Flutter framework intoBUILT_PRODUCTS_DIRBUILT_PRODUCTS_DIRtoTARGET_BUILD_DIRBUILT_PRODUCTS_DIR&TARGET_BUILD_DIR(which would have been put there by Xcode via SwiftPM) matches the Flutter framework in the engine cache.flutter assembleto copy the correct Flutter framework intoBUILT_PRODUCTS_DIRBUILT_PRODUCTS_DIRtoTARGET_BUILD_DIR.Fixes #166489.
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.