Open vashworth opened 1 week ago
May want to consider doing before adding official documentation on flutter build macos-framework
.
That's a good idea. I always get caught up on the naming here. A lot of folks don't know what "darwin" means. We could alias both flutter build ios-framework
and flutter build macos-framework
to it though.
Use case
When using Flutter in an add-to-app scenario, the native project it's being added to may support both iOS and macOS. When using
flutter build ios-framework
, it produces iOS-only xcframeworks. When usingflutter build macos-framework
, it produces macOS-only xcframeworks. If you're using a plugin that's both iOS and macOS compatible, like shared_preferences, for example, it'll produce 2 xcframeworks, both namedshared_preferences_foundation.xcframework
, one with iOS arch and one with macOS arch.If you try to link both versions of
shared_preferences_foundation.xcframework
in Xcode, it only shows one in the interface (although it does link both). Also, it will error when you build with a message like:Would be better for Flutter to produce a single
shared_preferences_foundation.xcframework
with all the architectures.Proposal
Perhaps combine the commands into a single
flutter build darwin-framework
that will check if the project supports iOS or macOS or both and then produce the needed xcframeworks with the needed architectures. Also, will need to figure out how to produce theGeneratedPluginRegistrant
.For Swift Package Manager add-to-app scenario, this could be a little easier, as you can use a TargetDependencyCondition to include targets dependencies by platform