5 minute quickstart

iOS Quickstart

Create an account

The first thing you need to do to get started with Firebase is sign up for a free account. A brand new Firebase will automatically be created for you with its own unique URL ending in firebaseio.com. We'll use this URL to store and sync data.

Download SDK

There are multiple ways to include the Firebase SDK into an Xcode project. We can use CocoaPods, manually include the framework and its dependencies, or use with Ruby Motion.


CocoaPods is the fastest way to get up and running with Firebase in your iOS app. Just add the following to your Podfile, pod install, and skip to Getting started in Xcode

pod 'Firebase', '>= 2.2.2'

Download Firebase.framework

Download the iOS SDK from the Firebase CDN, unzip the Firebase SDK file, drag the .framework folder to your XCode project under Frameworks, and skip to Installing the SDK.

Ruby Motion

For setting up Ruby Motion, check out our Ruby Motion installation guide.

Installing the SDK

Frameworks & Dependencies

Firebase depends on these other frameworks. Add them to your project:


Classes & Categories

Firebase makes use of Objective-C classes and categories, so we'll need to add this under "Other Linker Flags" in Build Settings:


Can't find the "Other Linker Flags" option?

If the "Other Linker Flags" option isn't showing, make sure the tabs in the top left of the Build Settings section are set to "All" and "Combined" rather than "Basic" and "Levels". "Other Linker Flags" is available in the "Linking" subsection.

Getting started in Xcode


Include the Firebase header in your app to get all the needed classes:

#import <Firebase/Firebase.h>


To use Swift with the iOS SDK we need to setup a bridging header. If you do not already have a bridging header, you can create one in Xcode by:

  1. If you have a Swift project, add a new Objective-C File to the project called Temp. If you have an Objective-C project, add a new Swift file called Temp.
  2. When prompted to configure an Objective-C bridging header, select "Yes."
  3. This creates the bridging header file, which ends in -Bridging-Header.h.
  4. Deleted the Temp file you created from your project.
  5. Import Firebase into your bridging header.
#import <Firebase/Firebase.h>

This is the only import you need. You will now be able to use Firebase in any of your Swift files!

Read & Write to your Firebase

Writing data

Getting data into Firebase is a cinch. We first need to create a reference to our Firebase, using our URL endpoint. Once we have a reference to your Firebase, we can write any valid JSON object to it using setValue.

// Create a reference to a Firebase location
Firebase *myRootRef = [[Firebase alloc] initWithUrl:@"https://myapp.firebasio-demo.com/"];
// Write data to Firebase
[myRootRef setValue:@"Do you have data? You'll love Firebase."];
// Create a reference to a Firebase location
var myRootRef = Firebase(url:"https://<your-firebase>.firebaseio.com/")
// Write data to Firebase
myRootRef.setValue("Do you have data? You'll love Firebase.")

Reading data

Firebase will stream data in realtime to any client that is listening. To setup a listener we need to call the observeEventType method. We will use the FEventTypeValue to listen for all changes. Then we'll add a block that returns a FDataSnapshot object that contains our data.

// Read data and react to changes
[myRootRef observeEventType:FEventTypeValue withBlock:^(FDataSnapshot *snapshot) {
  NSLog(@"%@ -> %@", snapshot.key, snapshot.value);
// Read data and react to changes
myRootRef.observeEventType(.Value, withBlock: {
  snapshot in
  println("\(snapshot.key) -> \(snapshot.value)")
Call value on the FDataSnapshot returned from the callback to access the data.

In the example above, the value event will fire once for the initial state of the data, and then again every time the value of that data changes. You can learn more about the various event types and how to handle event data in our documentation on reading data.

Add Authentication

Firebase provides full support for authenticating users. For common login options, such as email and password, Facebook, Twitter and Google, checkout out guide on User Authentication provides a quick way to get started. More advanced users may want to use custom login for complete control over user management and authentication.

Use Firebase to manage your authentication

Secure Your Firebase

Use our powerful expression-based Security and Firebase Rules to control access to your data and validate input:

  ".read": true,
  ".write": "auth.uid === 'admin'",
  ".validate": "newData.isString() && newData.val().length < 500"

Firebase enforces your Security and Firebase Rules consistently whenever data is accessed. The rules language is designed to be both powerful and flexible, so that you can maintain fine-grained control over your application's data.

What's Next?