Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Firebase iOS

Add Firebase to your iOS Project

Prerequisites

Before you begin, you need a few things set up in your environment:
  • Xcode 7.0 or later
  • An Xcode project targeting iOS 7 or above
  • The bundle identifier of your app
  • CocoaPods 1.0.0 or later.
If you don't have an Xcode project already, you can download one of our quickstart samples if you just want to try a Firebase feature. If you're using a quickstart, remember to get the bundle identifier from the project settings, you'll need it for the next step.


Note: If you are upgrading from a 2.X version of the Firebase SDK, see our upgrade guide for iOS to get started.

Add Firebase to your app

It's time to add Firebase to your app. To do this you'll need a Firebase project and a Firebase configuration file for your app.
  1. Create a Firebase project in the Firebase console, if you don't already have one. If you already have an existing Google project associated with your mobile app, click Import Google Project. Otherwise, click Create New Project.
  2. Click Add Firebase to your iOS app and follow the setup steps. If you're importing an existing Google project, this may happen automatically and you can just download the config file.
  3. When prompted, enter your app's bundle ID. It's important to enter the bundle ID your app is using; this can only be set when you add an app to your Firebase project.
  4. At the end, you'll download a GoogleService-Info.plist file. You can download this file again at any time.
  5. If you haven't done so already, copy this into your Xcode project root.


Note: If you have multiple build variants with different bundle IDs defined, each app must be added to your project in Firebase console.

Add the SDK

If you are setting up a new project, you need to install the SDK. You may have already completed this as part of creating a Firebase project.
We recommend using CocoaPods to install the libraries. You can install Cocoapods by following the installation instructions. If you'd rather not use CocoaPods, you can integrate the SDK frameworks directly by following the instructions below.
If you are planning to download and run one of the quickstart samples, the Xcode project and Podfile are already present, but you'll still need to install the pods and download the GoogleService-Info.plist file. If you would like to integrate the Firebase libraries into one of your own projects, you will need to add the pods for the libraries that you want to use.
  1. If you don't have an Xcode project yet, create one now.
  2. Create a Podfile if you don't have one:






    $ cd your-project directory
    $ pod init
  3. Add the pods that you want to install. You can include a Pod in your Podfile like this:






    pod 'Firebase/Core'
    This will add the prerequisite libraries needed to get Firebase up and running in your iOS app, along with Firebase Analytics. A list of currently available pods and subspecs is provided below. These are linked in feature specific setup guides as well.
  4. Install the pods and open the .xcworkspace file to see the project in Xcode.






    $ pod install
    $ open your
    -project.xcworkspace
  5. Download a GoogleService-Info.plist file from Firebase console and include it in your app.


Note: If you have multiple bundle IDs in your project, each bundle ID must be connected in Firebase console so it can have its own GoogleService-Info.plist file.

Initialize Firebase in your app

The final step is to add initialization code to your application. You may have already done this as part of adding Firebase to your app. If you are using a quickstart this has been done for you.
  1. Import the Firebase module in your UIApplicationDelegate subclass:

    SWIFT

    OBJECTIVE-C









    import Firebase
  2. Configure a FIRApp shared instance, typically in your application's application:didFinishLaunchingWithOptions: method:

    SWIFT

    OBJECTIVE-C









    // Use Firebase library to configure APIs
    FIRApp.configure()

Available Pods

These pods are available for the different Firebase features.
PodService
pod 'Firebase/Core'Prerequisite libraries and Analytics
pod 'Firebase/AdMob'AdMob
pod 'Firebase/Messaging'Cloud Messaging / Notifications
pod 'Firebase/Database'Realtime Database
pod 'Firebase/Invites'Invites
pod 'Firebase/DynamicLinks'Dynamic Links
pod 'Firebase/Crash'Crash Reporting
pod 'Firebase/RemoteConfig'Remote Config
pod 'Firebase/Auth'Authentication
pod 'Firebase/Storage'Storage


This post first appeared on See Something New, please read the originial post: here

Share the post

Firebase iOS

×

Subscribe to See Something New

Get updates delivered right to your inbox!

Thank you for your subscription

×