Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): support for using SPM (Swift Package Manager) #12786

Merged
merged 49 commits into from
Sep 12, 2024

Conversation

russellwheatley
Copy link
Member

@russellwheatley russellwheatley commented May 15, 2024

Description

  • Works with SPM and Cocoapods. To use SPM, remove Podfile as well as run pod deintegrate in the example/ios directory. You will know it worked when you don't see Running pod install... in the logs when running flutter run.
  • Package.swift does not have the same attributes that a podspec has. For example, you cannot set version, summary, description, homepage, license & authors.
  • Updated LIBRARY_VERSION and LIBRARY_NAME so the "@" symbol is in the code. I could not get the "@" character to escape in the Package.swift file causing build problem. I've also updated the podspec file to match.
  • Finally found a way to get firebase_core version and firebase-ios-sdk version dynamically in Package.swift file. Followed example of brave here. This works when running in Xcode and via Flutter CLI.
  • I've used firebase app installations as a product so we have access to firebase core, SPM doesn't ship firebase core as a standalone product.

TODO

  • check how the other plugins work with the updates.
  • update macOS podspec in firebase_core.
  • write integration tests building with SPM.
  • update macOS Package.swift to also extract versions dynamically. Test on Xcode build and via Flutter CLI
  • Update integration test for macOS to check it also works via SPM. Extract into a shell script as it is becoming unmanageable.

Related Issues

Replace this paragraph with a list of issues related to this PR from the issue database. Indicate, which of these issues are resolved or fixed by this PR. Note that you'll have to prefix the issue numbers with flutter/flutter#.

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]).
This will ensure a smooth and quick review process. Updating the pubspec.yaml and changelogs is not required.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (melos run analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change.
  • No, this is not a breaking change.

@russellwheatley russellwheatley marked this pull request as draft May 16, 2024 14:25
@russellwheatley russellwheatley changed the title feat(core): support for package swift feat(core): support for using SPM (Swift Package Manager) May 24, 2024
@russellwheatley russellwheatley marked this pull request as ready for review May 28, 2024 15:26
@loic-sharma
Copy link
Contributor

loic-sharma commented Aug 21, 2024

@russellwheatley Excellent work!

Did you follow Flutter's Swift Package Manager migration guide to create this pull request? If so, what problems did you run into? Do you have any feedback on the guide and how we could improve it?

@russellwheatley russellwheatley changed the base branch from master to main September 4, 2024 07:48
@russellwheatley
Copy link
Member Author

Hey @loic-sharma - thanks! Sorry for the late response. I actually used the instructions on the pull request which seems like a precursor to the documentation you linked. It was actually a pretty good guide!

The only trouble I ran into was project specific such as being able to get the firebase-ios-sdk version from within Package.swift file, and also trying to parse preprocessor definitions 😄

@charafau
Copy link
Contributor

Looks like in order to support other packages, this one needs to get merged first. It would be also good to have one plugin migrated to show how to get flutter core package in spm

let package = Package(
name: "firebase_core",
platforms: [
.iOS("12.0"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

good catch 👍

@russellwheatley russellwheatley merged commit 4e28103 into main Sep 12, 2024
24 of 26 checks passed
@russellwheatley russellwheatley deleted the spm-core-2 branch September 12, 2024 11:01
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.

5 participants