Install Firebase with Swift Package Manager

Starting with v8.0.0 of the Firebase iOS SDK, Firebase's Swift Package Manager support is out of beta and is generally available for use. CocoaPods is not required for Swift Package Manager users.

Via Xcode

Swift Package Manager support requires Xcode 12.5 or higher.

  1. If migrating from a CocoaPods-based project, run pod deintegrate to remove CocoaPods from your Xcode project. The CocoaPods-generated .xcworkspace file can safely be deleted afterward. If you're adding Firebase to a project for the first time, this step can be ignored.

  2. In Xcode, install the Firebase libraries by navigating to File > Swift Packages > Add Package Dependency…

  3. In the prompt that appears, select the Firebase GitHub repository:

    https://github.com/firebase/firebase-ios-sdk.git
    
  4. Select the version of Firebase you want to use. For new projects, we recommend using the newest version of Firebase.

  5. Choose the Firebase products you want to include in your app.

Once you're finished, Xcode will begin resolving your package dependencies and downloading them in the background.

Via Package.swift

To integrate Firebase to a Swift package via a Package.swift manifest, you can add Firebase to the dependencies array of your package. For more details, see the Swift Package Manager documentation.

dependencies: [

  .package(name: "Firebase",
           url: "https://github.com/firebase/firebase-ios-sdk.git",
           from: "8.0"),
  // ...

],

Then in any target that depends on a Firebase product, add it to the dependencies array of that target.

.target(
  name: "MyTargetName",
  dependencies: [
    .product(name: "FirebaseAuth", package: "Firebase"),
    // ...
  ]
),

Product-specific considerations

Some Firebase products require extra integration steps in order to function correctly.

Google Analytics

Google Analytics requires adding the -ObjC linker flag to your target's build settings.

Crashlytics

Crashlytics requires you to upload debug symbols.

You can use a run script for Xcode to automatically upload debug symbols post-build. Find the run script here:

${BUILD_DIR%Build/*}/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run

Another option for uploading symbols is to use the upload-symbols script. Place the script in a subdirectory of your project file (for example scripts/upload-symbols), then make sure that the script is executable:

chmod +x scripts/upload-symbols

This script can be used to manually upload dSYM files. For usage notes and additional instructions for the script, run upload-symbols without any parameters.