diff --git a/Flutter.xcframework.zip b/Flutter.xcframework.zip deleted file mode 100644 index eb8361f..0000000 Binary files a/Flutter.xcframework.zip and /dev/null differ diff --git a/Package.swift b/Package.swift index 84eff44..aa58051 100644 --- a/Package.swift +++ b/Package.swift @@ -32,24 +32,17 @@ func tryGuessSwiftRoot() -> String { } let SwiftRoot = EnvSysRoot ?? tryGuessSwiftRoot() -var FlutterPlatform: String +var FlutterPlatform: String = "" var FlutterUnsafeLinkerFlags: [String] = [] -#if os(macOS) // Note: This is the _build_ platform -// platformSwiftSettings += [] +// On Darwin (macOS/iOS), Flutter.framework / FlutterMacOS.framework is provided +// by the consumer Xcode project (via $(FRAMEWORK_SEARCH_PATHS) populated by +// Flutter's xcode_backend.sh / macos_assemble.sh build phases). FlutterSwift +// therefore declares no Darwin framework dependency at the package level; +// `swift build` outside of Xcode will compile the codecs but `canImport` will +// hide the Messenger. -let FlutterRoot = "/opt/flutter" -let _FlutterLibPath = "\(FlutterRoot)/bin/cache/artifacts/engine" - -FlutterPlatform = "darwin-x64" -let FlutterFramework = "FlutterMacOS" -let FlutterLibPath = "\(_FlutterLibPath)/\(FlutterPlatform)" -FlutterUnsafeLinkerFlags = [ - "-Xlinker", "-F", "-Xlinker", FlutterLibPath, - "-Xlinker", "-rpath", "-Xlinker", FlutterLibPath, - "-Xlinker", "-framework", "-Xlinker", FlutterFramework, -] -#elseif os(Linux) +#if os(Linux) // FIXME: this is clearly not right let FlutterRoot = ".build/artifacts/flutterswift/CFlutterEngine/flutter-engine.artifactbundle" #if arch(arm64) @@ -526,7 +519,6 @@ let package = Package( name: "FlutterSwift", dependencies: [ .target(name: "CxxFlutterSwift", condition: .when(platforms: [.linux])), - .target(name: "Flutter", condition: .when(platforms: [.iOS])), .product(name: "AsyncAlgorithms", package: "swift-async-algorithms"), .product(name: "Atomics", package: "swift-atomics"), "AsyncExtensions", @@ -534,7 +526,7 @@ let package = Package( cxxSettings: platformCxxSettings, swiftSettings: platformSwiftSettings, linkerSettings: [ - .unsafeFlags(FlutterUnsafeLinkerFlags, .when(platforms: [.macOS, .linux])), + .unsafeFlags(FlutterUnsafeLinkerFlags, .when(platforms: [.linux])), ] ), .testTarget( @@ -545,13 +537,9 @@ let package = Package( cxxSettings: platformCxxSettings, swiftSettings: platformSwiftSettings, linkerSettings: [ - .unsafeFlags(FlutterUnsafeLinkerFlags, .when(platforms: [.macOS, .linux])), + .unsafeFlags(FlutterUnsafeLinkerFlags, .when(platforms: [.linux])), ] ), - .binaryTarget( - name: "Flutter", - path: "Flutter.xcframework.zip" - ), ] + targets, cLanguageStandard: .c17, cxxLanguageStandard: .cxx17 diff --git a/README.md b/README.md index 276c532..7ac90f4 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,9 @@ The following assumes a reasonable degree of familiarity both with Flutter (spec On mobile and desktop platforms such as macOS, iOS and Android, the `FlutterPlatformMessenger` class wraps the platform's existing [binary messenger](https://api.flutter.dev/flutter/services/BinaryMessenger-class.html). This is due to the platform binary messenger not being replaceable, as it is used by host platform plugins. -On Darwin platforms (that is, iOS and macOS), you can simply add FlutterSwift as a Swift package dependency from Xcode. On Android, you will need to link FlutterSwift into a Java Native Interface (JNI) library that is bundled with your APK (more of which below). +On Darwin platforms (that is, iOS and macOS), you can simply add FlutterSwift as a Swift package dependency from Xcode. `Flutter.framework` / `FlutterMacOS.framework` is provided by your Flutter project's own xcconfig (via `xcode_backend.sh` / `macos_assemble.sh`), so FlutterSwift declares no Darwin framework dependency at the package level and ships no bundled Flutter binaries — the same mechanism Flutter's SwiftPM-aware plugins (e.g. `url_launcher_macos`) use. Note that standalone `swift build` on Darwin therefore compiles only the codecs; `FlutterPlatformMessenger` is `#if canImport`'d out unless built inside an Xcode project that wires up Flutter. + +On Android, you will need to link FlutterSwift into a Java Native Interface (JNI) library that is bundled with your APK (more of which below). ### Embedded platforms