This article contains a step by step guide explaining how to integrate Firebase SDKs into your IOS Project.
First of all, you need to create a project into Firebase Console if you have not already created it. To create a project into Firebase Console you can follow our guide, Firebase integration for beginners.
Steps to Integrate Firebase into Your IOS Project
1. Go to Firebase Console and click on your Project you just created in the previous guide.
2. On the project page, you will see an option to add a platform to your Project. Click on the IOS Platform. The screenshot is the following.
Register IOS App on Firebase
3. On the next page, you need to add your App details. IOS bundle Id, Your App Nickname (App will be visible in Firebase Console with this name) and optional App Store Id (If the app is already published on Appstore). After filling the details, press the Register App button, as shown in the following screenshot.
4. Firebase will automatically create a file named
GoogleService-Info.plist. you need to download it and add it to your project. For that open your Xcode, and drag and drop the file from your Finder window to the left Project Navigator under your project directory, as shown in the following screenshot.
Add Firebase SDK Pods into IOS Project
5. Now you need to add Firebase SDK into your IOS project. You only need to add that SDK which service you need to use, like Firebase Authentication, Firebase Database, Storage and others. Here you can find the List of Firebase SDKs for IOS. Here in the demo, I will only add Firebase Analytics.
6. Firebase recommends using Cocoapods to import its libraries. If Cocoapods is not installed in your Mac, follow these Guidelines to Install Cocoapods into Mac. If it’s already installed you can skip.
7. Now, open the Terminal window and navigate to your project directory and run the following command to create
PodFile in your project. If you have already created
PodFile for some other Pods, you can skip this step as well. The screenshot is the following.
8. Now open your
PodFile in Xcode and add Firebase Pods under
target 'YOU_PROJECT' do use_frameworks! like,
target 'YOUR_PROJECR' do # Comment the next line if you don't want to use dynamic frameworks use_frameworks! # Pods for YOUR_PROJECR pod 'Firebase/Analytics'
9. Now in your terminal, navigate to your project directory & run the following command. It will download Firebase libraries and will add to your project.
10. Now close Xcode and open it again by clicking on the newly generated file
Your_Project.xcworkspace file from your project directory. Also, don’t forget to click on Continue to Console button in your Firebase console to complete your IOS App registration. As shown in the following screenshot.
11. Now the final step is to initialize Firebase SDK in your project. For that add the following code in your
application didFinishLaunchingWithOptions method.
That’s it!! This is how you can Integrate Firebase SDKs into IOS Project. Now you can build your App and enjoy Firebase Libraries 🙂
You can also find other useful helping materials and tutorials in our Coding Articles & Tutorials Knowledge Base.