Skip to content

Add Swift Package Manager Support - #60

Closed
CanadianN1nj4 wants to merge 9 commits into
WebEferen:masterfrom
CanadianN1nj4:master
Closed

CanadianN1nj4 wants to merge 9 commits into
WebEferen:masterfrom
CanadianN1nj4:master

Conversation

@CanadianN1nj4

Copy link
Copy Markdown
Contributor

To help enable a clean transition to Swift Package Manager(SPM), I have followed the instructions from the official documentation: https://docs.flutter.dev/packages-and-plugins/swift-package-manager/for-plugin-authors#how-to-add-swift-package-manager-support-to-an-existing-flutter-plugin

Support for Cocoapods is still maintained.

Old redundant objective C files were removed from the project.

Automatic migrations to SPM were used. The example project readme was also updated to include details on how to run the project via cocoapods. (Automatic migration wouldn't happen because of the abnormal podsfile)

Environment versions were bumped following the instructions. Minimum iOS version was also bumped.

@CanadianN1nj4

Copy link
Copy Markdown
Contributor Author

@WebEferen could you please check this out to enable Swift Package Manager please?

@WebEferen

Copy link
Copy Markdown
Owner

Sure! Thanks for the request and the pull request. Will check it today

@WebEferen

WebEferen commented May 21, 2026 •

Copy link
Copy Markdown
Owner

Seems like the CI checks are failing, could you please fix them? @CanadianN1nj4 (bump dart/flutter version [3.44.0 - flutter])

@CanadianN1nj4

Copy link
Copy Markdown
Contributor Author

@WebEferen Updated!

@CanadianN1nj4

Copy link
Copy Markdown
Contributor Author

Sorry, realized I made a silly mistake. SPM only needs dart/flutter 3.5.0/2.24.0. Updated to fix this

@WebEferen WebEferen left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking on the SPM migration — adding Swift Package Manager support is a good direction for this plugin, and keeping CocoaPods support during the transition is important.

I found a few issues that look build-breaking for the SPM path:

  • ios/flutter_wallet_card/Package.swift declares the target as flutter-wallet-card, but the source file is under Sources/flutter_wallet_card. SwiftPM defaults to Sources/<target name>, so it will not find the source directory as written. Please either rename the target to flutter_wallet_card or set an explicit target path.
  • The target name is hyphenated. SwiftPM targets are Swift modules, so the target/module should use a valid Swift module identifier, normally the plugin name with underscores (flutter_wallet_card).
  • The manifest links .product(name: "FlutterFramework", package: "FlutterFramework"), while the Swift file imports Flutter. Please double-check this against Flutter's SPM plugin-author template; if the linked product does not provide the Flutter module, iOS builds will fail with no such module 'Flutter'.
  • The example Xcode project still has a stale ../../ios/my_plugin file reference, which looks like an automatic migration artifact.
  • Since CocoaPods support is meant to remain, please also confirm the pod path still builds after moving the Swift source and changing s.source_files. The example now renames Podfile to Podfile.template and removes Pods xcconfig includes, so it would be helpful to document and test both flutter build ios with SPM and the manual CocoaPods flow.

Could you fix the Package.swift target/module setup and clean the example project artifacts, then include confirmation that both SPM and CocoaPods builds work?

@GregoryPardini

GregoryPardini commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Hi @CanadianN1nj4, since this PR has been quiet since the July review, I've addressed the requested changes on top of your commits in #65 (your commits are kept). Happy to close mine if you'd rather continue here.

@CanadianN1nj4

Copy link
Copy Markdown
Contributor Author

Thanks @GregoryPardini I've been far too busy to be able work on this so I greatly appreciate the help!

WebEferen pushed a commit that referenced this pull request Oct 6, 2026
* add Swift Package Manager support

* migrate example app to swift package manager

* use local relative path for new swift package

* Add back podfile as a template to ensure non SPM users can run the example app

* remove dead code

* bump flutter and dart versions

* update incorrectly required dart/flutter version

* update example folder with swift package manager

* Update to use flutter 3.44.0 as the minimum and also update changelog

* fix(ios): use flutter_wallet_card as SwiftPM package and target name

The target was named flutter-wallet-card, which is not a valid Swift module
name and does not match Sources/flutter_wallet_card. Follow Flutter's plugin
template: package and target use the plugin name, the library product uses
the hyphenated name.

* chore(example): remove stale my_plugin file reference

Leftover from the automatic SPM migration. The plugin local override
(../../ios/flutter_wallet_card) and FlutterFramework references added by
Flutter are kept.

* fix(ios): align podspec minimum iOS version with Package.swift (13.0)

* ci: build with both Swift Package Manager and CocoaPods

Once migrated, the example app cannot be built with SPM disabled (same as
the example generated by flutter create -t plugin), so Podfile.template is
removed. The CocoaPods integration is checked by building a new app that
depends on the plugin with SPM disabled. Both flows are documented in the
example README.

* style: apply dart format tall style

The SDK constraint bump to ^3.12.0 enables the tall formatter style,
so CI's dart format check failed on the existing code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: remove upper bound from flutter SDK constraint

pub publish --dry-run warns on caret constraints for the Flutter SDK.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* build(example): bump Gradle 8.14.3, AGP 8.11.1, Kotlin 2.2.20

Flutter 3.44 rejects Gradle < 8.7. Also pin Kotlin's JVM target to 17
to match the Java compile options.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Thomas Sutlovic <Thomas.Sutlovic@ama.ab.ca>
Co-authored-by: Thomas Sutlovic <tsutlovic@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

3 participants