【发布时间】:2019-03-20 22:15:44
【问题描述】:
将 Xcode 迁移到 10 后,一个 iOS 项目(在以前的 Xcode 9 上完美构建和运行)在编译期间崩溃并出现“Segmentation fault 11”
我确实将我的 MacOS 升级到 Mojave,但问题仍然存在。
我收到以下错误:
在发出 SIL 时 'application(_:didRegisterForRemoteNotificationsWithDeviceToken:)' 在
/Users/swanandpatil/Desktop/omerApp/CustomerApp/AppDelegate.swift:955:5
- 虽然silgen emitFunction SIL功能 “@$S17CustomerApp0C8DelegateC11application_48didRegisterForRemoteNotifications WithDeviceTokenySo13UIApplicationC_10Foundation4DataVtF”。 在 /Users/swanandpatil/Desktop/RSA247CustomerApp/RSA247CustomerApp/AppDelegate.swift:955:5 的“应用程序(_:didRegisterForRemoteNotificationsWithDeviceToken:)” 错误:分段错误:11
下面是我的代码:
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 )");
}
}
【问题讨论】:
-
错误提示问题与
didRegisterForRemoteNotificationsWithDeviceToken有关 -
请不要只发布屏幕截图,而是复制/粘贴整个错误,不仅仅是“段错误 11”,而是导致它的原因,它上面的内容。
-
我认为这是一个 Xcode 错误。您必须发布代码(AppDelegate.swift,第 955 行及周边)。
-
这是完整的错误 1. 在 /Users/swanandpatil/Desktop/RSA247CustomerApp/RSA247CustomerApp/AppDelegate.swift:955:5 2 . 而 silgen emitFunction SIL 函数“@$S17RSA247CustomerApp0C8DelegateC11application_48didRegisterForRemoteNotificationsWithDeviceTokenySo13UIApplicationC_10Foundation4DataVtF”。 'application(:didRegisterForRemoteNotificationsWithDeviceToken:)' at /Users/swanandpatil/Desktop/RSA247CustomerApp/RSA247CustomerApp/AppDelegate.swift:955:5 错误:分段错误:11
-
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(描述:token2)"); } }
标签: ios swift xcode xcode10 ios12