Matan Mashraki
  • Welcome to my wiki!
  • iOS Development
    • Firebase + Carthage
Powered by GitBook
On this page
  • Let's start!
  • Step 1: Download Carthage
  • Step 2: Create a Cartfile
  • Step 3: Copy Firebase to Project
  • Step 4: Build Settings
  • Step 5: Build Phases
  • Step 6: Add some additional libraries if needed

Was this helpful?

  1. iOS Development

Firebase + Carthage

Make your compile times much faster with Carthage! (Updated to Xcode 11)

Using Firebase with Carthage makes your compile times much faster compared to CocoaPods. That's because with CocoaPods you need to recompile your project including Firebase on every archive or clean build. With Carthage, Firebase is pre-compiled.

Let's start!

Step 1: Download Carthage

We'll download Carthage with Homebrew.

$ brew update
$ brew install carthage

Step 2: Create a Cartfile

Create a Cartfile at the root of your project directory, copy the text below and remove the binaries you don't need.

Cartfile
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseABTestingBinary.json"
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseAdMobBinary.json"
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseAnalyticsBinary.json"
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseAuthBinary.json"
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseCrashlyticsBinary.json"
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseDatabaseBinary.json"
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseDynamicLinksBinary.json"
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseFirestoreBinary.json"
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseFunctionsBinary.json"
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseGoogleSignInBinary.json"
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseInAppMessagingBinary.json"
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseMessagingBinary.json"
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseMLModelInterpreterBinary.json"
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseMLVisionBinary.json"
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebasePerformanceBinary.json"
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseProtobufBinary.json"
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseRemoteConfigBinary.json"
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseStorageBinary.json"

FirebaseAnalyticsBinary must be included.

After you saved your new Cartfile, run the following command:

$ carthage update --platform ios

Step 3: Copy Firebase to Project

Open Carthage/Build/iOS on Finder.

Open your project on Xcode and go to your project settings. Select your target from the left, click "General" and scroll down to "Frameworks, Libraries, and Embedded Content".

Drag everything on Carthage/Build/iOS and drop in "Frameworks, Libraries, and Embedded Content". Make sure to set the "Embed" option to "Do Not Embed".

Step 4: Build Settings

Go to your target "Build Settings", select "All" and search for "Other Linker Flags". Change its value to $(OTHER_LDFLAGS) -ObjC

Step 5: Build Phases

Go to your target "Build Phases" and select "Link Binary With Libraries". Make sure all that frameworks you added are there and their status is "Required".

Next, delete Firebase.framework from "Link Binary With Libraries".

Step 6: Add some additional libraries if needed

Run the following command in your project directory:

$ cat Carthage/Build/iOS/*/Modules/module.modulemap | grep "link"

You'll see all the libraries that Firebase needs. Look at the output and identify libraries that aren't always available (e.g. AuthenticationServices, UIKit, Foundation).

The libraries I needed were "z", "c++" and "sqlite3".

Go back to your target "General", scroll down to "Frameworks, Libraries, and Embedded Content" and the libraries you need.

Click the + icon, and search for lib[name].tbd

Repeat steps 3 to 6 for every target in your project.

That's it! Now you can compile and enjoy the sweet faster compiling.

This article is updated to Xcode 11.

PreviousWelcome to my wiki!

Last updated 4 years ago

Was this helpful?