Latest Posts

Sorry, no posts matched your criteria.

Stay in Touch With Us

Odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore.

Email
magazine@example.com

Phone
+32 458 623 874

Addresse
302 2nd St
Brooklyn, NY 11215, USA
40.674386 – 73.984783

Follow us on social

The Gadget Book

How to Add Firebase to your iOS Applications using Cocoapods

Learn How to add Firebase to your iOS Applications using Cocoapods.

Firebase offers functionality like analytics, databases, messaging and crash reporting  and much more, Its used by loads of Development teams around the world—including NPR, Shazam, Duolingo, and Venmo.

Firebase Features

First create a project in the console and then click Add project, then give it a name.

Click Add Firebase to your iOS app and follow the setup steps. You will need to enter the Bundle ID for your app and a name you also have the option of entering a App Store id. It’s important to enter the bundle ID your Xcode app is using; this can only be set when you add an app to your Firebase project.

At the end, you’ll download a GoogleService-Info.plist  file which you will need to add to your Xcode project. Make sure the file is included in your app’s build target. 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 these instructions. After you have installed CocoaPods you will need to add the pods for the libraries that you want to use.

Open Terminal and direct yourself to your Xcode project, here we want to create a Podfile. 

 cd your-project directory
 pod init

You then need to add the Pods you want to use.

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'FirebaseSocialNetwork' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

  # Pods for FirebaseSocialNetwork

   pod 'Firebase/Core’

  target 'FirebaseSocialNetworkTests' do
    inherit! :search_paths
    # Pods for testing
  end

  target 'FirebaseSocialNetworkUITests' do
    inherit! :search_paths
    # Pods for testing
  end

end

This will add the libraries needed to get up and running, along with Google Analytics for Firebase. Jump back into Terminal and install the Pod file.

 pod install

Direct yourself to the Project Folder and open the “.workspace” project file, make sure you use the .workspace file from now on.

The final step is to initialise Firebase in your application. Import the Firebase module in your UIApplicationDelegate. In the didFinishLaunchingWithOptions method configure Firebase.

 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
         FirebaseApp.configure()
        return true
    }

Hit Build and Run and your Project should be running with no errors. If you had any problems or came across some errors hit us up on out social networks or leave a comment.

Post a Comment

You don't have permission to register