Skip to content

feat(macos): add Swift Package Manager support#99

Open
vitormf wants to merge 1 commit into
leanflutter:mainfrom
vitormf:main
Open

feat(macos): add Swift Package Manager support#99
vitormf wants to merge 1 commit into
leanflutter:mainfrom
vitormf:main

Conversation

@vitormf
Copy link
Copy Markdown

@vitormf vitormf commented May 21, 2026

Closes #98

Summary

Flutter 3.22+ detects SPM support in a plugin by looking for Package.swift at macos/<plugin_name>/Package.swift — specifically a subdirectory named after the plugin, not at macos/Package.swift directly. This PR adds that file in the correct location so Flutter 3.44+ (which defaults to SPM) no longer warns that tray_manager doesn't support Swift Package Manager.

Changes

  • macos/tray_manager/Package.swift — new SPM manifest; path: "Classes" points to the sources inside the package directory
  • macos/tray_manager/Classes/ — Swift sources moved from macos/Classes/ (SPM cannot reference paths outside the package root)
  • macos/tray_manager.podspecsource_files updated from Classes/**/* to tray_manager/Classes/**/* so CocoaPods still resolves correctly

CocoaPods 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 Integration Result
3.44.0 SPM (default) ✅ builds
3.44.0 CocoaPods ✅ builds
3.22.1 CocoaPods ✅ builds

flutter pub get no longer lists tray_manager under "The following plugins do not support Swift Package Manager".

Notes

  • Sources remain in a Classes/ directory (keeping the existing Flutter plugin convention) — only the parent path changes from macos/Classes/ to macos/tray_manager/Classes/
  • No public API changes; no Dart-side changes

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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Swift Package Manager support

1 participant