Firebase Unique Identifier (user id) not being recognized and app crashes when trying to access Database? Swift iOS9
<p>In my app I downloaded and installed the pods including Firebase/FirebaseAuth/FirebaseDatabase/FirebaseStorage/etc, used FIRApp.configure() in my AppDelegate, etc. I successfully logged users in and out and was able to upload/download data. All of a sudden Firebase isn't recognizing my user UUID. I'm not sure why but it just stopped.</p>

<p>Once the app loads everything is fine (still no UUID but the app actually loads) but if I try to go to a screen that would have to connect to Firebase to get upload/download data it crashes. It happens on every screen that needs to access Firebase but not the other ones. I added a ColorController view controller below to show the line the crash happens on.</p>

<p>In my AppDelegate 'didFinishLaunchingWithOptions' I added some code to check wether the app is connected to Firebase and it logs as "successfully connected". However I also added some code to check for the UUID in a print statement and it returns nil.</p>

<p>Any ideas?</p>

<pre><code>import UIKit
import Firebase
import FirebaseAuth
import FirebaseDatabase
import FirebaseStorage
import GoogleMaps

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    override init() {
        super.init()

        //Configure App for FireBase
        FIRApp.configure()

        //Firebase app Offline Updates
        FIRDatabase.database().persistenceEnabled = true

        GMSServices.provideAPIKey("myAPIKey")
    }//end override init


func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -&gt; Bool {

    //Make sure the app is connected to Firebase
    let connectedRef = FIRDatabase.database().referenceWithPath(".info/connected")
    connectedRef.observeEventType(.Value, withBlock: { 

        (connected) in

    let currentUserID = FIRAuth.auth()?.currentUser?.uid

    if let boolean = connected.value as? Bool where boolean == true {
         //This line successfully prints
         print("\nApp Delegate: Firebase is successfully connected\n")
         print("\nApp Delegate: UUID is \(currentUserID)\n")
    } else {
         print("\nApp Delegate: Firebase is NOT connected\n")
         }
   })


    if currentUserID != nil{
         print("\nApp Delegate: UUID is \(currentUserID)\n")
    } else{
         //These 2 lines print and UUID prints as "nil"
         print("\nApp Delegate: No User ID Available\n")
         print("\nApp Delegate: UUID is \(currentUserID)\n")
    }
}
</code></pre>

<p>Here is one of the view controllers that has access to Firebase but crashes</p>

<pre><code>import UIKit
import Firebase
import FirebaseAuth
import FirebaseDatabase

class ColorController: UIViewController {

@IBOutlet weak var colorLabel: UILabel!

var dbRef: FIRDatabaseReference!
let userID = FIRAuth.auth()?.currentUser?.uid

override func viewDidLoad() {
      super.viewDidLoad()

   //I tried both of these Separately. I commented out the one I didn't use
   self.dbRef = FIRDatabase.database().referenceFromURL("https://myApp.firebaseio.com")

   //I also tried switching to
   self.dbRef = FIRDatabase.database().reference()
}

override func viewWillAppear(animated: Bool) {
        super.viewWillAppear(true)

   let usersRef = self.dbRef.child("users")//it crashes on this line
   let userIDRef = usersRef.child(userID!)
   let colorData = userIDRef.child("colorData")

   colorData.observeEventType(.Value, withBlock: {

        (snapshot) in

      if let dict = snapshot.value as? [String:AnyObject]{

         let chosenColor = dict["chosenColor"] as? String

         self.colorLabel = chosenColor!
    }
  })
 }
}
</code></pre>

<p>Here is the crash from the ColorController</p>

<pre><code>//this is from line 'let usersRef = self.dbRef.child("users")'
Thread1: EXC_BAD_INSTRUCTION (code=EXC_1386_INVOP, subcode=0x0)
</code></pre>