【问题标题】:After convert to Swift3, ios app crashed : Thread 1: signal SIGABRT in class AppDelegate转换为 Swift3 后,ios 应用程序崩溃:线程 1:AppDelegate 类中的信号 SIGABRT
【发布时间】:2016-06-20 09:40:02
【问题描述】:

我的原始应用程序使用 xcode 7 在 swift2.3 中正常运行,但是在我使用 xcode 8 转换为 swift3.0 后,出现许多错误,然后我将其全部修复。我运行我的 swift3 应用程序没有错误,但是!它在着陆页中崩溃,并显示错误消息

线程 1:AppDelegate 类中的信号 SIGABRT

当应用程序在 swift2.3 中运行时,解析和核心数据仍然没有问题。 我还尝试了其他解决方案,例如 1.将所有隐私添加到 info.plist 文件中

<key>NSRemindersUsageDescription</key>
<string>&quot;Do u allow us to use it?&quot;</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>&quot;Do u allow us to use it?&quot;</string>
<key>kTCCServiceMediaLibrary</key>
<string>&quot;Do u allow us to use it?&quot;</string>
<key>NSMotionUsageDescription</key>
<string>&quot;Do u allow us to use it?&quot;</string>
<key>NSMicrophoneUsageDescription</key>
<string>&quot;Do u allow us to use it?&quot;</string>
<key>NSAppleMusicUsageDescription</key>
<string>&quot;Do u allow us to use it?&quot;</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>&quot;Do u allow us to use it?&quot;</string>
<key>NSLocationUsageDescription</key>
<string>&quot;Do u allow us to use it?&quot;</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>&quot;Do u allow us to use it?&quot;</string>
<key>NSHomeKitUsageDescription</key>
<string>&quot;Do u allow us to use it?&quot;</string>
<key>NSHealthUpdateUsageDescription</key>
<string>&quot;Do u allow us to use it?&quot;</string>
<key>NSHealthShareUsageDescription</key>
<string>&quot;Do u allow us to use it?&quot;</string>
<key>NSContactsUsageDescription</key>
<string>&quot;Do u allow us to use it?&quot;</string>
<key>NSCameraUsageDescription</key>
<string>&quot;Do u allow us to use it?&quot;</string>
<key>NSCalendarsUsageDescription</key>
<string>&quot;Do u allow us to use it?&quot;</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>&quot;Do u allow us to use it?&quot;</string>

2.检查我所有关于缺少链接问题的故事板,仍然没有解决。

参考:

  1. https://forums.developer.apple.com/thread/48959
  2. https://teamtreehouse.com/community/error-message-thread-1-signal-sigabrt-in-class-appdelegate

这是我的代码:

import UIKit
import CoreData
import Parse
import Bolts

@available(iOS 10.0, *)
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?


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

    // [Optional] Power your app with Local Datastore. For more info, go to
    // https://parse.com/docs/ios/guide#local-datastore
    Parse.enableLocalDatastore()

    // Initialize Parse. demo ID and Key
    Parse.setApplicationId("test123456789102293953543545",
        clientKey: "test09987654321234567890987654321")

    // [Optional] Track statistics around application opens.
    PFAnalytics.trackAppOpened(launchOptions: launchOptions)

    // Change the navifation background color
    UINavigationBar.appearance().barTintColor = UIColor(red: 216.0/255.0, green: 51.0/255.0, blue: 29.0/255.0, alpha: 1.0)

    // Change the navigation bar button color
    UINavigationBar.appearance().tintColor = UIColor.white()

    // Change the text font style and color
    if let barFont = UIFont(name: "AvenirNextCondensed-DemiBold", size: 22.0) {
        UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName:UIColor.white(), NSFontAttributeName:barFont]
    }

    // Change the status bar appearence
    UIApplication.shared().statusBarStyle = .lightContent

    // Change toolbar style
    // Font color
    // UIBarButtonItem.appearance().tintColor = UIColor(red: 255.0/255.0, green: 255.0/255.0, blue: 255.0/255.0, alpha: 0.5)

    // Background color
    // UIToolbar.appearance().barTintColor = UIColor(red: 237.0/255.0, green: 240.0/255.0, blue: 243.0/255.0, alpha: 0.5)

    // Edit tab bar appearence
    UITabBar.appearance().tintColor = UIColor(red: 216.0/255.0, green: 51.0/255.0, blue: 29.0/255.0, alpha: 1.0)

    UITabBar.appearance().barTintColor = UIColor.black()

    UITabBar.appearance().selectionIndicatorImage = UIImage(named: "tabitem_selected")

    return true
}

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:.
}


// MARK: - Core Data stack

lazy var applicationDocumentsDirectory: URL = {
    // The directory the application uses to store the Core Data store file. This code uses a directory named "com.jiro9611.CoreDataDemo" in the application's documents Application Support directory.
    let urls = FileManager.default().urlsForDirectory(.documentDirectory, inDomains: .userDomainMask)
    return urls[urls.count-1]
}()

lazy var managedObjectModel: NSManagedObjectModel = {
    // The managed object model for the application. This property is not optional. It is a fatal error for the application not to be able to find and load its model.
    let modelURL = Bundle.main().urlForResource("Zokoma", withExtension: "momd")!
    return NSManagedObjectModel(contentsOf: modelURL)!
}()

lazy var persistentStoreCoordinator: NSPersistentStoreCoordinator = {
    // The persistent store coordinator for the application. This implementation creates and returns a coordinator, having added the store for the application to it. This property is optional since there are legitimate error conditions that could cause the creation of the store to fail.
    // Create the coordinator and store
    let coordinator = NSPersistentStoreCoordinator(managedObjectModel: self.managedObjectModel)
    let url = try! self.applicationDocumentsDirectory.appendingPathComponent("Zokoma.sqlite")
    var failureReason = "There was an error creating or loading the application's saved data."
    do {
        try coordinator.addPersistentStore(ofType: NSSQLiteStoreType, configurationName: nil, at: url, options: nil)
    } catch {
        // Report any error we got.
        var dict = [String: AnyObject]()
        dict[NSLocalizedDescriptionKey] = "Failed to initialize the application's saved data"
        dict[NSLocalizedFailureReasonErrorKey] = failureReason

        dict[NSUnderlyingErrorKey] = error as NSError
        let wrappedError = NSError(domain: "YOUR_ERROR_DOMAIN", code: 9999, userInfo: dict)
        // Replace this with code to handle the error appropriately.
        // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
        NSLog("Unresolved error \(wrappedError), \(wrappedError.userInfo)")
        abort()
    }

    return coordinator
}()


lazy var managedObjectContext: NSManagedObjectContext? = {
    // Returns the managed object context for the application (which is already bound to the persistent store coordinator for the application.) This property is optional since there are legitimate error conditions that could cause the creation of the context to fail.
    let coordinator = self.persistentStoreCoordinator
    var managedObjectContext = NSManagedObjectContext(concurrencyType: .mainQueueConcurrencyType)

    managedObjectContext.persistentStoreCoordinator = coordinator
    return managedObjectContext
}()

// MARK: - Core Data Saving support

func saveContext () {
    if managedObjectContext!.hasChanges {
        do {
            try managedObjectContext!.save()
        } catch {
            // Replace this implementation with code to handle the error appropriately.
            // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
            let nserror = error as NSError
            NSLog("Unresolved error \(nserror), \(nserror.userInfo)")
            abort()
            }
        }
    }
}

调试控制台错误信息(线程 1 : 12 main)

2016-06-20 17:27:54.918235 testdemo[11372:336115] bundleid: com.jiro9611.testdemo.testdemo, enable_level: 0, persist_level: 0, propagate_with_activity: 0
2016-06-20 17:27:54.919918 testdemo[11372:336148] subsystem: com.apple.UIKit, category: HIDEvents, enable_level: 0, persist_level: 0, default_ttl: 0, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0, enable_oversize: 0, privacy_setting: 0
2016-06-20 17:27:54.967324 testdemo[11372:336115] Created DB, header sequence number = 252
2016-06-20 17:27:55.212898 testdemo[11372:336115] Created DB, header sequence number = 252
2016-06-20 17:27:55.817391 testdemo[11372:336115] subsystem: com.apple.BaseBoard, category: MachPort, enable_level: 0, persist_level: 0, default_ttl: 0, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0, enable_oversize: 0, privacy_setting: 0
2016-06-20 17:27:55.879995 testdemo[11372:336173] subsystem: com.apple.FrontBoard, category: Common, enable_level: 0, persist_level: 0, default_ttl: 0, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0, enable_oversize: 0, privacy_setting: 0
2016-06-20 17:27:56.123117 testdemo[11372:336315] subsystem: com.apple.network, category: , enable_level: 0, persist_level: 0, default_ttl: 0, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0, enable_oversize: 0, privacy_setting: 0
2016-06-20 17:27:56.126025 testdemo[11372:336332] subsystem: com.apple.SystemConfiguration, category: SCNetworkReachability, enable_level: 0, persist_level: 0, default_ttl: 0, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0, enable_oversize: 0, privacy_setting: 0
2016-06-20 17:27:56.161570 testdemo[11372:336318] [] nw_host_stats_add_src recv too small, received 24, expected 28
2016-06-20 17:27:56.161939 testdemo[11372:336318] [] nw_host_stats_add_src recv too small, received 24, expected 28
2016-06-20 17:27:56.162781 testdemo[11372:336318] [] nw_host_stats_add_src recv too small, received 24, expected 28
2016-06-20 17:27:56.163424 testdemo[11372:336318] [] nw_host_stats_add_src recv too small, received 24, expected 28
2016-06-20 17:27:56.165271 testdemo[11372:336318] [] nw_host_stats_add_src recv too small, received 24, expected 28
2016-06-20 17:27:56.166167 testdemo[11372:336318] [] nw_host_stats_add_src recv too small, received 24, expected 28
2016-06-20 17:27:56.168272 testdemo[11372:336318] [] nw_host_stats_add_src recv too small, received 24, expected 28
2016-06-20 17:27:56.169543 testdemo[11372:336318] [] nw_host_stats_add_src recv too small, received 24, expected 28
2016-06-20 17:27:56.207060 testdemo[11372:336326] [] nw_endpoint_handler_start [1 api.parse.com:443 initial path (null)]
2016-06-20 17:27:56.207989 testdemo[11372:336326] [] nw_connection_endpoint_report [1 api.parse.com:443 initial path (null)] reported event path:start
2016-06-20 17:27:56.209468 testdemo[11372:336326] [] nw_connection_endpoint_report [1 api.parse.com:443 waiting path (satisfied)] reported event path:satisfied
2016-06-20 17:27:56.212309 testdemo[11372:336326] subsystem: com.apple.SystemConfiguration, category: SCPreferences, enable_level: 0, persist_level: 0, default_ttl: 0, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0, enable_oversize: 0, privacy_setting: 0
2016-06-20 17:27:56.217287 testdemo[11372:336326] [] nw_connection_endpoint_report [1 api.parse.com:443 in_progress resolver (satisfied)] reported event resolver:start_dns
2016-06-20 17:27:56.224829 testdemo[11372:336325] [] nw_endpoint_resolver_update [1 api.parse.com:443 in_progress resolver (satisfied)] Adding endpoint handler for 52.86.231.34:443
2016-06-20 17:27:56.225499 testdemo[11372:336325] [] nw_endpoint_resolver_update [1 api.parse.com:443 in_progress resolver (satisfied)] Adding endpoint handler for 52.73.71.78:443
2016-06-20 17:27:56.226195 testdemo[11372:336325] [] nw_endpoint_resolver_update [1 api.parse.com:443 in_progress resolver (satisfied)] Adding endpoint handler for 54.236.65.43:443
2016-06-20 17:27:56.227043 testdemo[11372:336325] [] nw_endpoint_resolver_update [1 api.parse.com:443 in_progress resolver (satisfied)] Adding endpoint handler for 54.175.62.130:443
2016-06-20 17:27:56.228196 testdemo[11372:336325] [] nw_endpoint_resolver_update [1 api.parse.com:443 in_progress resolver (satisfied)] Adding endpoint handler for 52.73.46.179:443
2016-06-20 17:27:56.229822 testdemo[11372:336325] [] nw_endpoint_resolver_update [1 api.parse.com:443 in_progress resolver (satisfied)] Adding endpoint handler for 54.86.188.151:443
2016-06-20 17:27:56.231173 testdemo[11372:336325] [] nw_endpoint_resolver_update [1 api.parse.com:443 in_progress resolver (satisfied)] Adding endpoint handler for 52.72.176.218:443
2016-06-20 17:27:56.232084 testdemo[11372:336325] [] nw_endpoint_resolver_update [1 api.parse.com:443 in_progress resolver (satisfied)] Adding endpoint handler for 52.87.91.226:443
2016-06-20 17:27:56.232605 testdemo[11372:336325] [] nw_connection_endpoint_report [1 api.parse.com:443 in_progress resolver (satisfied)] reported event resolver:receive_dns
2016-06-20 17:27:56.233045 testdemo[11372:336325] [] nw_endpoint_resolver_start_next_child [1 api.parse.com:443 in_progress resolver (satisfied)] starting child endpoint 52.86.231.34:443
2016-06-20 17:27:56.234173 testdemo[11372:336325] [] nw_host_stats_add_src recv too small, received 24, expected 28
2016-06-20 17:27:56.236368 testdemo[11372:336325] [] nw_endpoint_resolver_start_next_child [1 api.parse.com:443 in_progress resolver (satisfied)] starting next child endpoint in 250ms
2016-06-20 17:27:56.236919 testdemo[11372:336325] [] nw_endpoint_handler_start [1.1 52.86.231.34:443 initial path (null)]
2016-06-20 17:27:56.237428 testdemo[11372:336325] [] nw_connection_endpoint_report [1.1 52.86.231.34:443 initial path (null)] reported event path:start
2016-06-20 17:27:56.238535 testdemo[11372:336325] [] nw_connection_endpoint_report [1.1 52.86.231.34:443 waiting path (satisfied)] reported event path:satisfied
2016-06-20 17:27:56.238915 testdemo[11372:336325] [] __nwlog_err_simulate_crash_libsystem libsystem simulate crash unavailable, [libsystem_network.dylib: nw_endpoint_get_hostname :: incorrect endpoint type 1]
2016-06-20 17:27:56.239684 testdemo[11372:336325] [] nw_endpoint_get_hostname incorrect endpoint type 1, dumping backtrace:
        [x86_64] libnetcore-805.0.0.2.2
    0   libsystem_network.dylib             0x000000010934c37f __nw_create_backtrace_string + 123
    1   libsystem_network.dylib             0x000000010934e46e nw_endpoint_get_hostname + 75
    2   libnetwork.dylib                    0x00000001095bfbe7 nw_endpoint_proxy_handler_should_use_proxy + 125
    3   libnetwork.dylib                    0x00000001095cd04f nw_endpoint_handler_path_change + 1509
    4   libnetwork.dylib                    0x00000001095cc8a2 nw_endpoint_handler_start + 570
    5   libnetwork.dylib                    0x00000001095e3026 nw_endpoint_resolver_start_next_child + 2050
    6   libdispatch.dylib                   0x00000001090a51e8 _dispatch_call_block_and_release + 12
    7   libdispatch.dylib                   0x00000001090d1dee _dispatch_client_callout + 8
    8   libdispatch.dylib                   0x00000001090aca1d _dispatch_queue_serial_drain + 239
    9   libdi
2016-06-20 17:27:56.241435 testdemo[11372:336325] [] nw_connection_endpoint_report [1.1 52.86.231.34:443 in_progress socket-flow (satisfied)] reported event flow:start_connect
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)

调试控制台错误信息“objc_release!!!” (线程 1:11 UIApplicationMain)

UIKit`UIApplicationMain:
0x1067c3dec <+0>:   pushq  %rbp
0x1067c3ded <+1>:   movq   %rsp, %rbp
0x1067c3df0 <+4>:   pushq  %r15
0x1067c3df2 <+6>:   pushq  %r14
0x1067c3df4 <+8>:   pushq  %r13
0x1067c3df6 <+10>:  pushq  %r12
0x1067c3df8 <+12>:  pushq  %rbx
0x1067c3df9 <+13>:  pushq  %rax
0x1067c3dfa <+14>:  movq   %rcx, %rbx
0x1067c3dfd <+17>:  movq   %rsi, -0x30(%rbp)
0x1067c3e01 <+21>:  movl   %edi, %r12d
0x1067c3e04 <+24>:  movq   0xeb33e5(%rip), %r13      ; (void *)0x0000000108264d20: objc_retain
0x1067c3e0b <+31>:  movq   %rdx, %rdi
0x1067c3e0e <+34>:  callq  *%r13
0x1067c3e11 <+37>:  movq   %rax, %r14
0x1067c3e14 <+40>:  movq   %rbx, %rdi
0x1067c3e17 <+43>:  callq  *%r13
0x1067c3e1a <+46>:  movq   %rax, %r15
0x1067c3e1d <+49>:  leaq   0xeb1478(%rip), %r13      ; _UIApplicationLinkedOnVersion
0x1067c3e24 <+56>:  movl   (%r13), %eax
0x1067c3e28 <+60>:  testl  %eax, %eax
0x1067c3e2a <+62>:  jne    0x1067c3e3a               ; <+78>
0x1067c3e2c <+64>:  cmpq   $-0x1, 0xeac3c4(%rip)     ; WebKitSetIsClassic + 7
0x1067c3e34 <+72>:  jne    0x1067c3ead               ; <+193>
0x1067c3e36 <+74>:  movl   (%r13), %eax
0x1067c3e3a <+78>:  cmpl   $0x20100, %eax            ; imm = 0x20100 
0x1067c3e3f <+83>:  jb     0x1067c3e65               ; <+121>
0x1067c3e41 <+85>:  callq  0x10739c10c               ; symbol stub for: objc_autoreleasePoolPush
0x1067c3e46 <+90>:  movq   %rax, %r13
0x1067c3e49 <+93>:  movl   %r12d, %edi
0x1067c3e4c <+96>:  movq   -0x30(%rbp), %rsi
0x1067c3e50 <+100>: movq   %r14, %rdx
0x1067c3e53 <+103>: movq   %r15, %rcx
0x1067c3e56 <+106>: callq  0x1067c3ec5               ; _UIApplicationMainPreparations
0x1067c3e5b <+111>: movq   %r13, %rdi
0x1067c3e5e <+114>: callq  0x10739c106               ; symbol stub for: objc_autoreleasePoolPop
0x1067c3e63 <+119>: jmp    0x1067c3e77               ; <+139>
0x1067c3e65 <+121>: movl   %r12d, %edi
0x1067c3e68 <+124>: movq   -0x30(%rbp), %rsi
0x1067c3e6c <+128>: movq   %r14, %rdx
0x1067c3e6f <+131>: movq   %r15, %rcx
0x1067c3e72 <+134>: callq  0x1067c3ec5               ; _UIApplicationMainPreparations
0x1067c3e77 <+139>: movq   0xeb1372(%rip), %rdi      ; UIApp
0x1067c3e7e <+146>: movq   0xe23e2b(%rip), %rsi      ; "_run"
0x1067c3e85 <+153>: callq  *0xeb3355(%rip)           ; (void *)0x0000000108267ac0: objc_msgSend
0x1067c3e8b <+159>: movq   0xeb3356(%rip), %rbx      ; (void *)0x0000000108264d90: objc_release
0x1067c3e92 <+166>: movq   %r15, %rdi
0x1067c3e95 <+169>: callq  *%rbx
0x1067c3e97 <+171>: movq   %r14, %rdi
0x1067c3e9a <+174>: callq  *%rbx
0x1067c3e9c <+176>: xorl   %eax, %eax
0x1067c3e9e <+178>: addq   $0x8, %rsp
0x1067c3ea2 <+182>: popq   %rbx
0x1067c3ea3 <+183>: popq   %r12
0x1067c3ea5 <+185>: popq   %r13
0x1067c3ea7 <+187>: popq   %r14
0x1067c3ea9 <+189>: popq   %r15
0x1067c3eab <+191>: popq   %rbp
0x1067c3eac <+192>: retq   
0x1067c3ead <+193>: leaq   0xeac344(%rip), %rdi      ; _UIApplicationLinkedOnVersionOnce
0x1067c3eb4 <+200>: leaq   0xeb68f5(%rip), %rsi      ; __block_literal_global.1569
0x1067c3ebb <+207>: callq  0x10739c940               ; symbol stub for: dispatch_once
0x1067c3ec0 <+212>: jmp    0x1067c3e36               ; <+74>

调试控制台错误信息(线程 1:13 开始)

libdyld.dylib`start:
0x1091276bc <+0>: nop    
0x1091276bd <+1>: movl   %eax, %edi
0x1091276bf <+3>: callq  0x1091276f6               ; symbol stub for: exit
0x1091276c4 <+8>: hlt   

调试控制台错误信息(线程 1:14 开始)

libdyld.dylib`start:
0x1091276bc <+0>: nop    
0x1091276bd <+1>: movl   %eax, %edi
0x1091276bf <+3>: callq  0x1091276f6               ; symbol stub for: exit
0x1091276c4 <+8>: hlt 

【问题讨论】:

  • 您的应用是否需要任何权限,例如访问位置、照片等?如果是这样,这是否在您的 plist / 项目设置中设置?
  • @ff10 是的,我确实需要访问用户照片库,并且我使用核心数据、发送电子邮件和分享到 facebook(如果用户在 iphone 中登录)。我在 info.plist 中添加所有隐私 - 选项,如下所示(我将所有设置添加到我的帖子中): NSRemindersUsageDescription"你允许我们使用它吗?" string> NSPhotoLibraryUsageDescription“你允许我们使用它吗?”
  • 添加您在问题中指定的所有密钥后,尝试在 info.plist 中添加隐私密钥。滚动 info.plist 中的可用密钥并添加所有隐私密钥,然后告诉我会发生什么。
  • @AlvinVarghese 我添加的密钥都是关于 info.plist 中的隐私密钥的。它有 16 个与隐私相关的密钥。或者我以错误的方式添加它(我的演示帖子),我只是在 value 列中为用户输入了一个字符串问题。
  • 我有同样的错误。我尝试在 info.plist 中添加隐私密钥,但似乎没有任何解决方案。我的错误与 AFNetworking 和 AFURLSessionManager 有关。

标签: ios swift swift3 ios10


【解决方案1】:

感谢所有给我建议的人,我终于解决了朋友教我的问题。我在这里分享这两个解决方案,希望可以帮助像我一样面临类似问题的其他人。

  1. xcode 8 beta 有时会错过断点。当我们调试的时候,我们设置了一些断点,但是 xcode 并没有停在我们设置的地方。原来错误是在我们之前设置的断点附近,但是xcode 8 beta并没有就此止步……最终我们使用本土方法一步步测试我的代码。

  2. 真正的错误是因为“核心数据”在swift 3.0中代码表达式发生了变化,更重要的是,编写核心数据的新方法并不意味着它可以解决。

例如:

旧方式(swfit2.2): 它会导致在xcode上显示错误,所以你必须改变它

let fetchRequest = NSFetchRequest(entityName: "Restaurant")

新方式(swift3.0): 这是我犯的关键错误,我遵循其他人的建议,将旧方法更改为此,xcode 没有显示错误警告,所以我只是运行应用程序,它崩溃了!!该代码行没有任何特定的错误点,就像我说的 xcode 8 deta 有时不能在断点处停止,所以它导致我们找到错误的方法。

let fetchRequest: NSFetchRequest<NSFetchRequestResult> = Restaurant.fetchRequest()

正确的新方式(swift3.0) 这是我运行应用程序时没有警告和工作发现的正确方法。

let fetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName: "Restaurant")

所以,这就是我的解决方案,在苹果开发者论坛和一些 stackoverflow 帖子中,人们都会像我一样收到类似的错误消息,但解决方案都是不同的。祝你好运!

【讨论】:

    【解决方案2】:

    通常,Thread 1: signal SIGABRT 错误的末尾有一条消息,其中包含更多指示。在你的情况下,libc++abi.dylib: terminating with uncaught exception of type NSException

    This SO answer 说它可能来自情节提要中的断开连接。 有时在迁移过程中会发生。你能看看那里吗?

    编辑:抱歉,我刚刚看到你已经测试过了。

    【讨论】:

    • 另外进行清理和构建(和/或)删除派生数据有时会有所帮助。
    • @blablalba 是的,我确实检查了所有的 segue 是否有黄色警告。我的应用程序运行时没有错误和警告。我做了所有清理和构建然后运行,仍然崩溃。我认为关键是这个错误消息“2016-06-23 11:39:52.576703 testapp[7660:315960] [] nw_endpoint_get_hostname 不正确的端点类型1,转储回溯:”这是什么意思nw_endpoint_get_hostname?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-11-08
    • 1970-01-01
    • 1970-01-01
    • 2019-01-29
    • 1970-01-01
    • 1970-01-01
    • 2020-07-16
    相关资源
    最近更新 更多