0

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 )");
    }
}
Andreas Oetjen
  • 9,889
  • 1
  • 24
  • 34
  • The error says that the issue is related to `didRegisterForRemoteNotificationsWithDeviceToken` – vadian Oct 16 '18 at 11:44
  • 1
    Please don't post only a screenshot, bu copy/past the whole error, not only "segment fault 11", but what leads to it, what's just above it. – Larme Oct 16 '18 at 11:55
  • I assume it's an Xcode bug. You'll have to post the code (AppDelegate.swift, line 955, and surroundings). – Andreas Oetjen Oct 16 '18 at 14:37
  • This is the complete error 1. While emitting SIL for 'application(_:didRegisterForRemoteNotificationsWithDeviceToken:)' at /Users/swanandpatil/Desktop/RSA247CustomerApp/RSA247CustomerApp/AppDelegate.swift:955:5 2. While silgen emitFunction SIL function "@$S17RSA247CustomerApp0C8DelegateC11application_48didRegisterForRemoteNotificationsWithDeviceTokenySo13UIApplicationC_10Foundation4DataVtF". for 'application(_:didRegisterForRemoteNotificationsWithDeviceToken:)' at /Users/swanandpatil/Desktop/RSA247CustomerApp/RSA247CustomerApp/AppDelegate.swift:955:5 error: Segmentation fault: 11 – user2606884 Oct 16 '18 at 17:05
  • 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 )"); } } – user2606884 Oct 16 '18 at 17:08
  • I tried commenting this function but no success – user2606884 Oct 16 '18 at 17:08

1 Answers1

2

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

Andreas Oetjen
  • 9,889
  • 1
  • 24
  • 34
  • :-1: Multiple commands produce '/Users/asd/Library/Developer/Xcode/DerivedData/CustomerApp-fqcceceikstdqzctsjuwfwrspvad/Build/Products/Debug-iphonesimulator/SwiftyGif/SwiftyGif.framework/Info.plist': 1) Target 'SwiftyGif' (project 'Pods') has copy command from '/Users/swanandpatil/Desktop/CustomerApp/Pods/SwiftyGif/SwiftyGif/Info.plist' to '/Users/swanandpatil/Library/Developer/Xcode/DerivedData/CustomerApp-fqcceceikstdqzctsjuwfwrspvad/Build/Products/Debug-iphonesimulator/SwiftyGif/SwiftyGif.framework/Info.plist' – user2606884 Oct 18 '18 at 04:31
  • 2) Target 'SwiftyGif' (project 'Pods') has process command with output '/Users/swanandpatil/Library/Developer/Xcode/DerivedData/CustomerApp-fqcceceikstdqzctsjuwfwrspvad/Build/Products/Debug-iphonesimulator/SwiftyGif/SwiftyGif.framework/Info.plist' – user2606884 Oct 18 '18 at 04:32
  • 1
    @user2606884 Please mark my answer as "accepted" if it solves your problem. To your second problem: This is something completely different. Typically, you should create individual questions for individual problems. In your special case, you could also take a look here: https://stackoverflow.com/questions/50718018/xcode-10-error-multiple-commands-produce – Andreas Oetjen Oct 18 '18 at 06:03