-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Add Flutter as a Swift Package dependency #178931
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is mimicking:
flutter/packages/flutter_tools/lib/src/macos/xcode.dart
Lines 285 to 293 in f63cf73
| EnvironmentType? environmentTypeFromSdkroot(String sdkroot, FileSystem fileSystem) { | |
| // iPhoneSimulator.sdk or iPhoneOS.sdk | |
| final String sdkName = fileSystem.path.basename(sdkroot).toLowerCase(); | |
| if (sdkName.contains('iphone')) { | |
| return sdkName.contains('simulator') ? EnvironmentType.simulator : EnvironmentType.physical; | |
| } | |
| assert(false); | |
| return null; | |
| } |
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is mimicking:
flutter/packages/flutter_tools/lib/src/artifacts.dart
Lines 954 to 966 in f63cf73
| for (final Directory platformDirectory | |
| in xcframeworkDirectory.listSync().whereType<Directory>()) { | |
| if (!platformDirectory.basename.startsWith('ios-')) { | |
| continue; | |
| } | |
| // ios-x86_64-simulator, ios-arm64_x86_64-simulator, or ios-arm64. | |
| final bool simulatorDirectory = platformDirectory.basename.endsWith('-simulator'); | |
| if ((environmentType == EnvironmentType.simulator && simulatorDirectory) || | |
| (environmentType == EnvironmentType.physical && !simulatorDirectory)) { | |
| return platformDirectory; | |
| } | |
| } | |
| throwToolExit('No iOS frameworks found in ${xcframeworkDirectory.path}'); |
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is mimicking:
flutter/packages/flutter_tools/lib/src/artifacts.dart
Lines 1026 to 1033 in f63cf73
| final Directory? platformDirectory = xcframeworkDirectory | |
| .listSync() | |
| .whereType<Directory>() | |
| .where((Directory platformDirectory) => platformDirectory.basename.startsWith('macos-')) | |
| .firstOrNull; | |
| if (platformDirectory == null) { | |
| throwToolExit('No macOS frameworks found in ${xcframeworkDirectory.path}'); | |
| } |
stuartmorgan-g
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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.