Skip to content

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

Open
vitormf wants to merge 3 commits into
TerminalStudio:mainfrom
vitormf:main
Open

feat(macos): add Swift Package Manager support#21
vitormf wants to merge 3 commits into
TerminalStudio:mainfrom
vitormf:main

Conversation

@vitormf

@vitormf vitormf commented May 21, 2026

Copy link
Copy Markdown

Summary

Flutter 3.22+ detects SPM support in a plugin by looking for Package.swift at macos/<plugin_name>/Package.swift. This PR adds that file so Flutter 3.44+ (which defaults to SPM) no longer warns that flutter_pty doesn't support Swift Package Manager for macOS.

Changes

  • macos/flutter_pty/Package.swift — new SPM manifest with a C target; path: "Classes" points to sources inside the package directory
  • macos/flutter_pty/Classes/ — sources moved from macos/Classes/; C forwarder updated from #include "../../src/flutter_pty.c" to #include "../../../src/flutter_pty.c" to match the new relative location
  • macos/flutter_pty.podspecsource_files updated from Classes/**/* to flutter_pty/Classes/**/* so CocoaPods still resolves correctly

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 flutter_pty under "The following plugins do not support Swift Package Manager for macos".

Notes

  • Only macOS SPM support is added in this PR; iOS would follow the same pattern
  • No public API changes; no Dart-side changes
  • The C forwarder include path update is the only code change — it now correctly points from macos/flutter_pty/Classes/ up three levels to src/

vitormf added 3 commits May 21, 2026 23:56
Dynamic SPM products are transitive deps of the static
FlutterGeneratedPluginSwiftPackage and Xcode does not auto-embed
them, causing a crash at launch. Declaring type: .static links
flutter_pty directly into the app binary with no embedding needed.
…k open

DynamicLibrary.open('flutter_pty.framework/flutter_pty') requires the
framework to be present in the app bundle. With SPM type: .static the
code is linked into the app binary but no .framework is embedded, so
dlopen fails at runtime.

DynamicLibrary.process() resolves symbols from the already-loaded
process image, which works for both SPM (static) and CocoaPods
(framework already mapped before Dart starts).
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.

1 participant