feat(macos): add Swift Package Manager support - #1
Open
tadelv wants to merge 1 commit into
Open
Conversation
Flutter 3.44 defaults to SPM; reaprime keeps SPM enabled on macOS, so the plugin needs a Package.swift (same migration as tadelv/dart_js c7cde7b for flutter_js). - restructure macos sources into macos/flutter_libserialport/Sources/ per the Flutter SPM plugin layout; podspec updated so CocoaPods integration keeps working (dual support) - add a libserialport C target compiled from copies of third_party/libserialport (SPM targets cannot reference files outside the package directory) with a configure-generated macOS config.h, mirroring the vendored-config approach of the android/linux/windows builds - ship the product as type .dynamic: dart:ffi needs a loadable binary for the sp_* symbols, and LGPL libserialport must stay a replaceable dynamic library - FlutterLibserialportPlugin now falls back to its own framework binary for LIBSERIALPORT_PATH when the CocoaPods libserialport.framework is absent (the C target lives inside the plugin framework under SPM) - example: commit Flutter's at-build-time SPM migration of the Runner project, and await SerialPort.availablePorts (async since the usb_serial fork changes) Verified: example builds and runs with SPM (framework exports 80 sp_* symbols, port enumeration clean) and builds with CocoaPods after restoring a pristine Runner project. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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
Flutter 3.44 enables Swift Package Manager by default. This adds a
Package.swiftfor macOS so the plugin resolves natively via SPM, while keeping full CocoaPods compatibility (dual support, as required by the Flutter plugin migration guide).Changes
macos/flutter_libserialport/Sources/per the Flutter SPM plugin layout; the podspec is re-pointed at the new path so CocoaPods integration keeps working.libserialportC target compiled from copies ofthird_party/libserialport(SPM targets cannot reference files outside the package directory) with a configure-generated macOSconfig.h— mirroring the vendored-config approach the android/linux/windows CMake builds already use.type: .dynamic: dart:ffi needs a loadable binary for thesp_*symbols, and LGPL libserialport should remain a separate, replaceable dynamic library.FlutterLibserialportPluginkeeps pointingLIBSERIALPORT_PATHat the CocoaPodslibserialport.frameworkwhen present, and falls back to its own framework binary under SPM (the C target is linked into the plugin's dynamic framework).await SerialPort.availablePorts(async since the usb_serial changes).Verification
flutter-libserialport.frameworkexports 80sp_*symbols, port enumeration works.flutter config --no-enable-swift-package-manager) from a pristine Runner project.🤖 Generated with Claude Code