Darwin: stop bundling Flutter framework; delegate to host Xcode project#24
Merged
Conversation
Removes two Darwin-specific assumptions baked into Package.swift: 1. /opt/flutter was hardcoded as the macOS Flutter SDK root — broke any developer whose SDK lived elsewhere, and was useless on Apple Silicon (darwin-x64 artifact name only). 2. Flutter.xcframework.zip (~63 MB) was committed in the repo and wired in as a .binaryTarget for iOS — pinned to whatever engine revision the zip was built against, bloated git history, and risked conflicting with the Flutter.framework the host Xcode project already provides. Both are removed. On Darwin, Flutter.framework / FlutterMacOS.framework is now sourced from the host Xcode project's $(FRAMEWORK_SEARCH_PATHS), populated by Flutter's standard xcode_backend.sh / macos_assemble.sh build phases — the same mechanism Flutter's SwiftPM-aware plugins (e.g. url_launcher_macos) rely on. SPM targets compiled within an Xcode build inherit those search paths, so `import FlutterMacOS` / `import Flutter` continues to resolve in FlutterPlatformMessenger.swift. Linux and Android (cross-compiled on macOS) code paths are untouched: the Linux branch still emits its own engine linker flags, and the Android branch still overwrites FlutterPlatform / FlutterUnsafeLinkerFlags downstream of the Darwin block. Tradeoff: standalone `swift build` on Darwin no longer pulls in the Flutter framework — FlutterPlatformMessenger is hidden by `#if canImport(...)`. This is acceptable because the example apps (and intended downstream consumers) reference FlutterSwift via XCLocalSwiftPackageReference, and Xcode always supplies the framework. README updated to call this out. Verified by: - swift test (28/28 pass) - flutter build macos --debug - flutter build ios --debug --no-codesign --simulator - gradlew :app:assembleDebug (Android arm64) - swift package describe (macOS, FLUTTER_SWIFT_JVM=true) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1a0e92a to
9d9859c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Removes two Darwin-specific assumptions baked into `Package.swift` that broke under common configurations:
Both are removed. On Darwin, `Flutter.framework` / `FlutterMacOS.framework` is now sourced from the host Xcode project's `$(FRAMEWORK_SEARCH_PATHS)`, populated by Flutter's standard `xcode_backend.sh` / `macos_assemble.sh` build phases — the same mechanism Flutter's SwiftPM-aware plugins (e.g. `url_launcher_macos`) rely on. SPM targets compiled within an Xcode build inherit those search paths, so `import FlutterMacOS` / `import Flutter` continues to resolve in `FlutterPlatformMessenger.swift`.
Linux and Android (cross-compiled on macOS) code paths are untouched: the Linux branch still emits its own engine linker flags, and the Android branch still overwrites `FlutterPlatform` / `FlutterUnsafeLinkerFlags` downstream of the Darwin block.
Tradeoff
Standalone `swift build` on Darwin no longer pulls in the Flutter framework — `FlutterPlatformMessenger` is hidden by `#if canImport(...)`. This is acceptable because the example apps (and intended downstream consumers) reference FlutterSwift via `XCLocalSwiftPackageReference` (path-based), and Xcode always supplies the framework. README updated to call this out.
Test plan
🤖 Generated with Claude Code