feat(macos): add Swift Package Manager support#99
Open
vitormf wants to merge 1 commit into
Open
Conversation
Add Package.swift at macos/ pointing at the existing Classes/ directory so Flutter 3.24+ can build this plugin via SPM. CocoaPods builds are unaffected — no files moved, no podspec changes. The only change to existing code is an explicit `import AppKit` in TrayIcon.swift — required under SPM's stricter module resolution (unlike CocoaPods, SPM does not implicitly import frameworks via DEFINES_MODULE).
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.
Closes #98
Summary
Flutter 3.22+ detects SPM support in a plugin by looking for
Package.swiftatmacos/<plugin_name>/Package.swift— specifically a subdirectory named after the plugin, not atmacos/Package.swiftdirectly. This PR adds that file in the correct location so Flutter 3.44+ (which defaults to SPM) no longer warns thattray_managerdoesn't support Swift Package Manager.Changes
macos/tray_manager/Package.swift— new SPM manifest;path: "Classes"points to the sources inside the package directorymacos/tray_manager/Classes/— Swift sources moved frommacos/Classes/(SPM cannot reference paths outside the package root)macos/tray_manager.podspec—source_filesupdated fromClasses/**/*totray_manager/Classes/**/*so CocoaPods still resolves correctlyCocoaPods builds are unaffected — the podspec continues to work from
macos/tray_manager.podspec, just with an updated source path.Compatibility
Tested across three configurations:
flutter pub getno longer liststray_managerunder "The following plugins do not support Swift Package Manager".Notes
Classes/directory (keeping the existing Flutter plugin convention) — only the parent path changes frommacos/Classes/tomacos/tray_manager/Classes/