Search code examples
iosswiftxcodexcode10ios12

xcode 10 migration error getting segment fault 11


After migration of Xcode to 10, an iOS project - which was building and running perfectly on previous Xcode 9 - is crashing during compilation with "Segmentation fault 11"

I did upgrade my MacOS to Mojave, but the issue is still there.

I get the following error:

  1. While emitting SIL for 'application(_:didRegisterForRemoteNotificationsWithDeviceToken:)' at

    /Users/swanandpatil/Desktop/omerApp/CustomerApp/AppDelegate.swift:955:5

  2. While silgen emitFunction SIL function "@$S17CustomerApp0C8DelegateC11application_48didRegisterForRemoteNotifications WithDeviceTokenySo13UIApplicationC_10Foundation4DataVtF". for 'application(_:didRegisterForRemoteNotificationsWithDeviceToken:)' at /Users/swanandpatil/Desktop/RSA247CustomerApp/RSA247CustomerApp/AppDelegate.swift:955:5 error: Segmentation fault: 11

Below is my code:

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    //print("deviceToken is \(deviceToken)");

    if let token = InstanceID.instanceID().token() {

        UserDefaults.standard.set(token, forKey:"fcm_tokenNew")
        let token2 = UserDefaults.standard.object(forKey:"fcm_tokenNew") as? String
        print("FCM TOKEN2 IS\(describing: token2 )");
    }
}

Solution

  • Congratulations, you found an Xcode compiler bug.

    The problem is here:

    print("FCM TOKEN2 IS\(describing: token2 )");
    

    The correct syntax would be:

     print("FCM TOKEN2 IS\(String(describing:token2))");
    

    The compiler should give you a meaningful error message, but instead is crashing.

    I already filed a radar: https://openradar.appspot.com/45330067