# Firebase Tutorial: Getting Started

**URL:** <https://forums.kodeco.com/t/firebase-tutorial-getting-started/6453>\
**Category:** 🎓 Courses & Articles\
**Created:** [March 4, 2016, 10:44am UTC](https://forums.kodeco.com/t/firebase-tutorial-getting-started/6453 "2016-03-04T10:44:26Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![davideast](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/davideast/32/340_2.png) [@davideast](https://forums.kodeco.com/u/davideast)\
**Post date:** [March 4, 2016, 10:44am UTC](https://forums.kodeco.com/t/firebase-tutorial-getting-started/6453/1 "2016-03-04T10:44:26Z")

</div>

In this Firebase tutorial, you'll learn about the fundamentals, including saving data, real-time sync, authentication, user status, and offline support.

* * *
 This is a companion discussion topic for the original entry at [https://www.raywenderlich.com/1610-firebase-tutorial-getting-started](https://www.raywenderlich.com/1610-firebase-tutorial-getting-started)

---

<div class="post-metadata">

**Author:** ![shuchen](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shuchen/32/12367_2.png) [@shuchen](https://forums.kodeco.com/u/shuchen)\
**Post date:** [March 8, 2016, 3:37am UTC](https://forums.kodeco.com/t/firebase-tutorial-getting-started/6453/2 "2016-03-08T03:37:47Z")

</div>

Wonderful job!

Hope you upload some tutorials on multi-media processing about Firebase in swift.  
Such as image/video upload/download, which is essential for a good app.

---

<div class="post-metadata">

**Author:** ![hgg](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/hgg/32/8846_2.png) [@hgg](https://forums.kodeco.com/u/hgg)\
**Post date:** [March 15, 2016, 7:34pm UTC](https://forums.kodeco.com/t/firebase-tutorial-getting-started/6453/3 "2016-03-15T19:34:29Z")

</div>

Nice tutorial David, very nice way to get started with Firebase. Would you have or would you know where I could find a very similar tutorial for Android?

Since you guys cover iOS and Android, I think it would be very beneficial to the community if you could provide your tutorials in SWIFT and Java (Android).

Thanks

---

<div class="post-metadata">

**Author:** ![linxy](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/linxy/32/12289_2.png) [@linxy](https://forums.kodeco.com/u/linxy)\
**Post date:** [March 29, 2016, 4:05pm UTC](https://forums.kodeco.com/t/firebase-tutorial-getting-started/6453/4 "2016-03-29T16:05:24Z")

</div>

Check out udacity. They have a full on FREE andorid-firebase course on a Shopping list app which is a lot more involved than this.

---

<div class="post-metadata">

**Author:** ![torres](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/torres/32/19904_2.png) [@torres](https://forums.kodeco.com/u/torres)\
**Post date:** [March 30, 2016, 4:05pm UTC](https://forums.kodeco.com/t/firebase-tutorial-getting-started/6453/5 "2016-03-30T16:05:58Z")

</div>

When “Observing Authentication State” we just check if the authData is nil, the thing is that it already has data every time the app starts, so every time I re-build it automatically goes to the grocery list view, shouldn’t the app always ask for credentials? we are not saving any token or credentials on the device, so if authData is retrieved from Firebase at start, how does the Firebase know which user is asking for authentication? or am I missing something?

---

<div class="post-metadata">

**Author:** ![ppdany](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/ppdany/32/77416_2.png) [@ppdany](https://forums.kodeco.com/u/ppdany)\
**Post date:** [March 31, 2016, 8:53pm UTC](https://forums.kodeco.com/t/firebase-tutorial-getting-started/6453/6 "2016-03-31T20:53:54Z")

</div>

HI there!

This tutorial is exactly what I need, but I’m getting errors and warnings when trying to compile the starter project. Am I the only one or is it because of the latest updates to OS X and Xcode (I have Version 7.3 (7D175))? I’m a bit of a newbie here so bear with me.

There are 3 errors, all of which have the message:  
Downcast from ‘UITableViewCell?’ to ‘UITableViewCell’ only unwraps optionals; did you mean to use ‘!’?

There are also 8 warnings but I didn’t really pay attention to them…

Any help would be greatly appreciated 😃

Happy coding!

---

<div class="post-metadata">

**Author:** ![torres](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/torres/32/19904_2.png) [@torres](https://forums.kodeco.com/u/torres)\
**Post date:** [April 1, 2016, 6:58pm UTC](https://forums.kodeco.com/t/firebase-tutorial-getting-started/6453/7 "2016-04-01T18:58:26Z")

</div>

I think this is because the tutorial was written before Swift 2.0 was implemented within Xcode, so, just change the “?” for “!” which is what I did and it worked correctly

---

<div class="post-metadata">

**Author:** ![torres](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/torres/32/19904_2.png) [@torres](https://forums.kodeco.com/u/torres)\
**Post date:** [April 4, 2016, 2:36am UTC](https://forums.kodeco.com/t/firebase-tutorial-getting-started/6453/8 "2016-04-04T02:36:24Z")

</div>

I’m getting the following error “thread 1 exc\_bad\_instruction (code=exc\_i386\_invop subcode=0x0)” at line 44 in the GroceryItem struct file “name = snapshot.value[“name”] as! String” it says in the console that “fatal error: unexpectedly found nil while unwrapping an Optional value” any ideas? I just downloaded the complete project and it is not working neither

---

<div class="post-metadata">

**Author:** ![ppdany](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/ppdany/32/77416_2.png) [@ppdany](https://forums.kodeco.com/u/ppdany)\
**Post date:** [April 5, 2016, 8:52pm UTC](https://forums.kodeco.com/t/firebase-tutorial-getting-started/6453/9 "2016-04-05T20:52:28Z")

</div>

This didn’t seem to do the full trick for me. See my response below.

---

<div class="post-metadata">

**Author:** ![ppdany](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/ppdany/32/77416_2.png) [@ppdany](https://forums.kodeco.com/u/ppdany)\
**Post date:** [April 5, 2016, 9:13pm UTC](https://forums.kodeco.com/t/firebase-tutorial-getting-started/6453/10 "2016-04-05T21:13:09Z")

</div>

Hello!

These are the changes I made for the errors from Swift 1 to Swift 2 and also additional notes on the tutorial.

**In GroceryListTableViewController.swift**  
For the warning in line 45, change the selector of userCountBarButtonItem from  
userCountBarButtonItem = UIBarButtonItem(title: “1”, style: UIBarButtonItemStyle.Plain, target: self, action: **Selector** (“userCountButtonDidTouch”))  
to  
userCountBarButtonItem = UIBarButtonItem(title: “1”, style: UIBarButtonItemStyle.Plain, target: self, action: **#selector(GroceryListTableViewController.userCountButtonDidTouch)**)

For the error in line 68, change the cell declaration from  
let cell = tableView.dequeueReusableCellWithIdentifier(“ItemCell”) **as! UITableViewCell**  
to  
let cell = tableView.dequeueReusableCellWithIdentifier(“ItemCell”**, forIndexPath: indexPath)**

For the error in line 126 change the textField declaration in line 126 from  
let textField = alert.textFields![0] **as! UITextField**  
to  
let textField = alert.textFields![0]

For the error in the following line (127) add **!** in the groceryItem declaration:  
let groceryItem = GroceryItem(name: textField.text, addedByUser: self.user.email, completed: false)  
to  
let groceryItem = GroceryItem(name: **textField.text!** , addedByUser: self.user.email, completed: false)

**In OnlineUsersTableViewController.swift**  
Change cell declaration in line 46 to clear the error from Swift 1 to Swift 2 from  
let cell = tableView.dequeueReusableCellWithIdentifier(UserCell) **as! UITableViewCell**  
to  
let cell = tableView.dequeueReusableCellWithIdentifier(UserCell, **forIndexPath: indexPath)**

**Additionally, In LoginViewController.swift**  
I changed the alert in line 48 from var to let since it does seem to only have one value.  
I also changed the emailField and passwordField declarations by removing “ **as! UITextField** ” so that it looks like this  
let emailField = alert.textFields![0]  
let passwordField = alert.textFields![1]  
but I don’t recall if this was absolutely necessary.

As for the tutorial itself, I have some notes:  
In section **Displaying a List of Online Users**

- The tutorial says to change _viewDidAppear_ but there is no _viewDidAppear_ code, do we add it or was _viewDidLoad_ the intended function? (both seem to work)
- In OnlineUsersTableViewController.swift there is no reference to _usersRef_ like in GroceryListTableViewController.swift, yet the tutorial assumes you already do or you already imported it. So, does it need to be added in the same way we did in the other file or should it be imported? (I just added it)
- For the last piece of code to be added in this section, change **enumerate(self.currentUsers)** and instead use **self.currentUsers.enumerate()** as the former gives error (I guess due to the Swift 2 changes).
- The tutorial says “Using a bit of trickery, it’s possible to add a user to Online…” if this sounded a bit ambiguous as there is no explicit mention of what that trickery means, the actual trick is to press the + button in the online data tree

Lastly, in the section **Enabling Offline**  
The code for **AppDelegate.swift** that we’re supposed to add is already added there in the starter project.

Hope this helps  
Happy coding!

---

<div class="post-metadata">

**Author:** ![jungle\_jim](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/jungle_jim/32/9701_2.png) [@jungle\_jim](https://forums.kodeco.com/u/jungle_jim)\
**Post date:** [April 7, 2016, 9:42am UTC](https://forums.kodeco.com/t/firebase-tutorial-getting-started/6453/11 "2016-04-07T09:42:43Z")

</div>

Thanks, this removed most errors. I still can’t compile though, I get a “linker command failed with exit code 1” error. Anyone know what I can do about this?

edit: never mind, I wasn’t working in the workspace 😅

---

<div class="post-metadata">

**Author:** ![jgurban](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/jgurban/32/81494_2.png) [@jgurban](https://forums.kodeco.com/u/jgurban)\
**Post date:** [April 8, 2016, 7:33am UTC](https://forums.kodeco.com/t/firebase-tutorial-getting-started/6453/12 "2016-04-08T07:33:53Z")

</div>

Hi,

I had the same problem and the way I solved it was making the totally installation of the Firebase pod from terminal.

-First, Xcode must be closed.

-Make all the installation of Firebase pod from Terminal:

cd your-xcode-project-directory  
pod init  
open -a Xcode Podfile

-Write the following in your Podfile

platform :ios, “8.0”  
use\_frameworks!  
target ‘the name of your Xcode-project’ do  
pod ‘Firebase’, ‘\>= 2.5.0’  
end

-The run the following from Terminal to install pod

pod install

-Once time you have finished with the installation of Firebase launch Xcode from Terminal:

open your-project.xcworkspace

Remember: The key here is that after the installation of Firebase Pod you have to launch your project from terminal and not from Xcode.

I hope it help you

Regards

---

<div class="post-metadata">

**Author:** ![alexknowsswift](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/alexknowsswift/32/81494_2.png) [@alexknowsswift](https://forums.kodeco.com/u/alexknowsswift)\
**Post date:** [April 28, 2016, 4:58pm UTC](https://forums.kodeco.com/t/firebase-tutorial-getting-started/6453/13 "2016-04-28T16:58:59Z")

</div>

The tutorial works great (with some minor fixes from outdated syntax) and builds fine on the simulator, however, if you want to test it out on the iPhone make sure you do the following:

- Go to **Build Settings**

- Underneath **Build Settings** scroll down to **Build Options**

- In **Build Options** , switch the **Enable Bitcode** setting to **No**

That should allow you to build and test the app on your iPhone,

I have a minor query about this tutorial; how come there’s no way for users to sign-out? While the sign up and login function work fine, it’s very difficult to test without having to delete and re-install the app because there’s absolutely no way for new users to sign-up as the build automatically segues directly to the Table View where the grocery list is.

The only way I have been able to get back into the LoginViewController to use the **Sign Up** function is if I build the app on different iOS Simulators (eg: iPhone 4s, 5, 5s etc…). 🤔

---

<div class="post-metadata">

**Author:** ![nobre84](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/nobre84/32/90749_2.png) [@nobre84](https://forums.kodeco.com/u/nobre84)\
**Post date:** [May 1, 2016, 2:17pm UTC](https://forums.kodeco.com/t/firebase-tutorial-getting-started/6453/14 "2016-05-01T14:17:11Z")

</div>

That’s expected behavior, when users sign in, they get their user stored in the app so they don’t need to sign in again.  
What I did to complete the features and be able to change users is a Sign out button in the first screen. What this does is simply a Exit segue to the LoginViewController, which calls ref.unauth() and Firebase.goOffline() so the user gets erased and the online monitoring consider the user offline on the other running apps.

---

<div class="post-metadata">

**Author:** ![nobre84](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/nobre84/32/90749_2.png) [@nobre84](https://forums.kodeco.com/u/nobre84)\
**Post date:** [May 1, 2016, 2:18pm UTC](https://forums.kodeco.com/t/firebase-tutorial-getting-started/6453/15 "2016-05-01T14:18:40Z")

</div>

Check my answer below about sign out functionality

---

<div class="post-metadata">

**Author:** ![jamiedaniel](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/jamiedaniel/32/109088_2.png) [@jamiedaniel](https://forums.kodeco.com/u/jamiedaniel)\
**Post date:** [May 9, 2016, 6:31am UTC](https://forums.kodeco.com/t/firebase-tutorial-getting-started/6453/16 "2016-05-09T06:31:07Z")

</div>

Trying to do this tutorial and I got to the first implementation of the first call to save an item and I get this:

```
2016-05-09 02:28:35.792 Grocr[26579:1592969] _BSMachError: (os/kern) invalid capability (20)
2016-05-09 02:28:35.792 Grocr[26579:1593630] _BSMachError: (os/kern) invalid name (15)

```

Anyone have any ideas why I am getting this?

I tried all the usual things - Google, removing line by line, adding line by line back… I get nothing!

Would love to do this tutorial for Firebase but it doesn’t seem to work anymore.

J

---

<div class="post-metadata">

**Author:** ![jacinmontava](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/jacinmontava/32/42746_2.png) [@jacinmontava](https://forums.kodeco.com/u/jacinmontava)\
**Post date:** [May 18, 2016, 12:51pm UTC](https://forums.kodeco.com/t/firebase-tutorial-getting-started/6453/17 "2016-05-18T12:51:34Z")

</div>

I have the same problem.

Have you find a solution?

---

<div class="post-metadata">

**Author:** ![davidcoronado](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/davidcoronado/32/32795_2.png) [@davidcoronado](https://forums.kodeco.com/u/davidcoronado)\
**Post date:** [May 20, 2016, 5:29pm UTC](https://forums.kodeco.com/t/firebase-tutorial-getting-started/6453/18 "2016-05-20T17:29:28Z")

</div>

Is there an updated version of this Tutorial since Swift 2.0 was released and Firebase is now powered by Google?

---

<div class="post-metadata">

**Author:** ![williammass](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/williammass/32/32858_2.png) [@williammass](https://forums.kodeco.com/u/williammass)\
**Post date:** [May 22, 2016, 4:21pm UTC](https://forums.kodeco.com/t/firebase-tutorial-getting-started/6453/19 "2016-05-22T16:21:29Z")

</div>

[Firebase] setValue: or removeValue: at /grocery-items/test failed: permission\_denied

I can’t even add an Item, just added the ref line, and updated the save function and fixed the errors… Is there a step I’m missing?

---

<div class="post-metadata">

**Author:** ![jacobsiegel](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/jacobsiegel/32/32973_2.png) [@jacobsiegel](https://forums.kodeco.com/u/jacobsiegel)\
**Post date:** [May 24, 2016, 3:21pm UTC](https://forums.kodeco.com/t/firebase-tutorial-getting-started/6453/20 "2016-05-24T15:21:58Z")

</div>

Anyway you can update this tutorial with the new firebase release? Thanks!

[Next page](https://forums.kodeco.com/t/firebase-tutorial-getting-started/6453.md?page=2)
