Airport Tutorial Error "fatal error: unexpectedly found nil while unwrapping an Optional value"

Basics
Xcode 7.3.1
iOS 9.3.2 (iPhone 4s (if you can believe it))
SDK 4.5.1

In Brief

  • Completed the “Show an ‘enter’ notification error” section of the tutorial
  • I get the following error upon running on my phone: fatal error: unexpectedly found nil while unwrapping an Optional value

This looks like the origin of it:

        self.beaconManager.startMonitoringForRegion(
            CLBeaconRegion(
            proximityUUID: NSUUID(UUIDString: "BB9407F30-F5F8-466E-AFF9-25556B57FE6D")!,
            major: 1, minor: 10, identifier: "monitored region")
        )

My full App Delegate Code:

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, ESTBeaconManagerDelegate {

    var window: UIWindow?
    let beaconManager = ESTBeaconManager()
    

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        // Override point for customization after application launch.
        self.beaconManager.delegate = self
        self.beaconManager.requestAlwaysAuthorization()

        
        self.beaconManager.startMonitoringForRegion(
            CLBeaconRegion(
            proximityUUID: NSUUID(UUIDString: "BB9407F30-F5F8-466E-AFF9-25556B57FE6D")!,
            major: 1, minor: 10, identifier: "monitored region")
        )

        
        UIApplication.sharedApplication().registerUserNotificationSettings(
            UIUserNotificationSettings(forTypes: .Alert, categories: nil))
        
        return true
    }
    
    func beaconManager(manager: AnyObject, didEnterRegion region: CLBeaconRegion) {
        let notification = UILocalNotification()
        notification.alertBody =
            "Take me to your leader"
        UIApplication.sharedApplication().presentLocalNotificationNow(notification)
    }
  

    func applicationWillResignActive(application: UIApplication) {
        // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
        // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
    }

    func applicationDidEnterBackground(application: UIApplication) {
        // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
        // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
    }

    func applicationWillEnterForeground(application: UIApplication) {
        // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
    }

    func applicationDidBecomeActive(application: UIApplication) {
        // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
    }

    func applicationWillTerminate(application: UIApplication) {
        // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
    }

}

Respective Screen Shots


Any ideas?
Many thanks in advance.
New to Swift and Xcode

PS - Unsure if this matters, but in case:
I did work through the tutorial (successfully I believe) on my phone with iOS 7.1.2 originally and then decided to upgrade to iOS 9.

You have a typo in your UUID, an extra “B” at the beginning:

BB9407F30-F5F8-466E-AFF9-25556B57FE6D

should be:

B9407F30-F5F8-466E-AFF9-25556B57FE6D

Typos, the nightmare of all the programmers :slight_smile:

Thanks and sorry you had to to that. I’ll go ahead and delete my post; it wont be helpful to others in light of the issue.

Nah, don’t worry, happens to all of us! (;