Header Ads Widget

Firebase SDK for Apple now fully supports Swift Package Manager

Peter Friese
Developer Advocate
Paul Beusterien
Software Engineer
Firebase header

Since Firebase first released an iOS SDK, CocoaPods has been the preferred way to add Firebase to your iOS projects. CocoaPods has served the iOS community well and has made adding libraries and frameworks as easy as adding their package name to your project's Podfile file and running pod install.

In recent years, Swift Package Manager has grown in popularity thanks to being officially supported by Apple, and its tight integration with Xcode. The 2020 iOS Developer Community Survey shows that more than 41% of app developers use Swift Package Manager in their business apps. For hobby/personal apps, that number is even higher at > 56% of developers using Swift Package Manager in their projects.

Adding support for Swift Package Manager has been one of the most requested features in our issue tracker:

image showing a comment from a user asking for iOS support

Firebase shipped initial (beta) support for Swift Package Manager in August 2020 with Firebase 6.31.0 for a partial set of Firebase products.

Today, we are excited to announce that as of Firebase 8.6.0 for iOS, Firebase fully supports Swift Package Manager. This means you can now add Firebase to your iOS project without leaving Xcode. Gone are the days of having to maintain a working Ruby installation, or having to remember the correct command line arguments just to be able to add a Swift library to your iOS project.

How to add Firebase using SwiftPM

Adding Firebase to your iOS project is easier than ever before with Xcode 12.5:

  • Open your iOS project in Xcode
  • Navigate to File > Swift Packages > Add Package Dependency
  • Insert the repository URL for Firebase (https://github.com/firebase/firebase-ios-sdk), and hit enter to install
  • Once Xcode has resolved all the dependencies, choose the Firebase products you would like to use in your project
  • Don't forget to download GoogleServices-Info.plist from your Firebase project and add it to your iOS project
GIF showing how to add Firebase to iOS app

Heavy lifting

Adding support for Swift Package Manager was a multi-year project that not only required us to refactor our directory structure and build options to conform to SwiftPM's requirements - we also worked closely with the SwiftPM community to resolve integration issues with binary libraries, resource support, and - last but not least - unit testing support.

Performance Monitoring was the last Firebase product that was missing support for Swift Package Manager, and just a few days ago, the Performance Monitoring team completed their work to get ready for SwiftPM. This involved substantial investment in migrating from Protobuf to nanopb, a refactoring that reduced the size of the SDK by more than 30%.

📦 Wrapping up

We know that many of you have been looking forward to being able to migrate to a SwiftPM-only project setup, and we're excited to be able to say that using Swift Package Manager is now the preferred way to add Firebase to your iOS project.

We're working on updating the documentation, setup flows, and quickstart apps to reflect this change.

Come visit us on our GitHub discussion board and issue tracker, and let us know what you think, or if you have any questions about migrating from CocoaPods to Swift Package Manager.

source http://firebase.googleblog.com/2021/08/firebase-swift-package-manager.html

Post a Comment