Skip to content

feat(ios): add Swift Package Manager support - #56

Closed
zoocityboy wants to merge 1 commit into
chore/updatefrom
feat/spm-support
Closed

zoocityboy wants to merge 1 commit into
chore/updatefrom
feat/spm-support

Conversation

@zoocityboy

Copy link
Copy Markdown

An SPM-only app (no ios/Podfile) cannot depend on this plugin: every published version — 1.0.1, 1.1.0, 1.2.0 — ships only ios/flutter_opendroneid.podspec. That blocks dronetag/app-ng, whose iOS target is SPM; filed there as .df/issues/flutteropendroneid-na-spm.md.

What changed

  • ios/flutter_opendroneid/Package.swift — one target, no ObjC, iOS 12.0.
  • Swift sources moved to ios/flutter_opendroneid/Sources/flutter_opendroneid/; the podspec's source_files follows them, so one tree serves CocoaPods and SwiftPM both.
  • ObjC registration shim removed (FlutterOpendroneidPlugin.{h,m}, flutter_opendroneid.h). It forwarded registerWithRegistrar to the Swift class and did nothing else; pubspec.yaml's ios pluginClass now names SwiftFlutterOpendroneidPlugin.
  • Podspec platform 8.0 → 12.0, matching Package.swift. The plugin class is already @available(iOS 13.0) and the legacy app targets 14/16, so nothing actually loses support.

Why against chore/update and not master

A single SwiftPM target cannot mix ObjC and Swift. master still carries the ObjC Pigeon bridge (ios/Classes/pigeon.{h,m}); 794bfb1 on this branch replaced it with Pigeon-generated Swift. On master this change would need a second ObjC target — I tried that base first and backed out.

CocoaPods consumers are unaffected: the podspec stays, and Flutter picks whichever the app uses.

Verified / not verified

swift package dump-package parses the manifest — one iOS 12.0 platform, product flutter-opendroneid, target flutter_opendroneid.

Not verified: a real device or simulator build, which needs macOS. Dropping the ObjC shim changes how registration happens, so that check is not optional before a release — it is in the issue's definition of done, along with publishing, which app-ng needs before it can take the plugin.

An app with no ios/Podfile — SPM-only, which is how dronetag/app-ng is set up —
could not depend on this plugin at all: every published version (1.0.1, 1.1.0,
1.2.0) shipped ios/flutter_opendroneid.podspec and no Package.swift. That is a
blocking finding for app-ng's R0.3, filed there as
.df/issues/flutteropendroneid-na-spm.md.

Package.swift is declared alongside the podspec rather than instead of it.
Flutter resolves whichever the consuming app uses, so an app on CocoaPods —
including the legacy dronetag/app — keeps working unchanged.

Sources move to the layout SwiftPM requires:

    ios/Classes/*.swift  →  ios/flutter_opendroneid/Sources/flutter_opendroneid/

and the podspec's source_files follows them, so one tree serves both.

The ObjC registration shim goes: FlutterOpendroneidPlugin.m forwarded
registerWithRegistrar to SwiftFlutterOpendroneidPlugin and nothing else, and
pubspec's ios pluginClass now names the Swift class directly. This is only
possible on this branch: a single SwiftPM target cannot mix ObjC and Swift, and
794bfb1 replaced the ObjC Pigeon bridge (ios/Classes/pigeon.{h,m}, still present
on master) with Pigeon-generated Swift. On master this change cannot be made
without keeping a second ObjC target.

Podspec platform 8.0 → 12.0 to match Package.swift. Not a real narrowing: the
plugin class is already @available(iOS 13.0) and the legacy app targets 14/16.

Verified: `swift package dump-package` parses the manifest — one iOS 12.0
platform, product flutter-opendroneid, target flutter_opendroneid. Not verified:
an actual device or simulator build, which needs macOS. That is in the issue's
definition of done and has to happen before a release.
@zoocityboy zoocityboy closed this Sep 9, 2026
@zoocityboy
zoocityboy deleted the feat/spm-support branch September 9, 2026 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant