Search code examples
iosswiftamazon-cognitoaws-mobilehubamazon-mobile-hub

Swift 3 - Thread 1: EXC_BAD_INSTRUCTION (code = EXC_I386_INVOP, subcode = 0x0)


I am trying to add user authentication functionality into my app using AWS Cognito as a backend.

So far I am getting this error whenever my app tries to build, and when it does it points to these errors in two of my classes.

AWSMobileClient Class:

func didFinishLaunching(application: UIApplication, withOptions launchOptions: [NSObject : AnyObject]?) -> Bool {
    print("didFinishLaunching:")


    let didFinishLaunching = AWSIdentityManager.defaultIdentityManager().interceptApplication(application, didFinishLaunchingWithOptions: launchOptions)

    if (!isInitialized) {
        AWSIdentityManager.defaultIdentityManager().resumeSession(completionHandler: {(_ result: AnyObject, _ error: Error) -> Void in
            print("result = \(result), error = \(error)")
        } as! (Any?, Error?) -> Void) --> ERROR ON THIS LINE <--
        isInitialized = true
    }
    return didFinishLaunching
}

AppDelegate Class:

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.
    return AWSMobileClient.sharedInstance.didFinishLaunching(application: application, withOptions: launchOptions as [NSObject : AnyObject]?) --> ERROR ON THIS LINE <--

Solution

  • Looks like AWS MobileHub sample code is not yet swift3 compatible--that is what I'm running in to; perhaps you as well? See here for an answer from AWS, and a hint to use the legacy compiler setting (which I've not sorted out just yet...)