首页 > 解决方案 > iPhone 应用程序在使用 SIGABRT 在 AppDelegate 中启动时崩溃

问题描述

我的应用程序实际上是在 20 分钟前启动的,但现在我什至无法让它加载登录屏幕而不会崩溃。它在 AppDelegate 上崩溃,控制台中唯一的错误是

terminating with uncaught exception of type NSException

在控制台中使用 bt 命令给出以下堆栈跟踪

* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    frame #0: 0x000000010bcea2c6 libsystem_kernel.dylib`__pthread_kill + 10
    frame #1: 0x000000010bd3dbf1 libsystem_pthread.dylib`pthread_kill + 284
    frame #2: 0x000000010ba76a3c libsystem_c.dylib`abort + 120
    frame #3: 0x000000010acc37f8 libc++abi.dylib`abort_message + 231
    frame #4: 0x000000010acc39c7 libc++abi.dylib`demangling_terminate_handler() + 262
    frame #5: 0x0000000109e0dd7c libobjc.A.dylib`_objc_terminate() + 96
    frame #6: 0x000000010acd0e97 libc++abi.dylib`std::__terminate(void (*)()) + 8
    frame #7: 0x000000010acd0ae9 libc++abi.dylib`__cxa_rethrow + 99
    frame #8: 0x0000000109e0dcb4 libobjc.A.dylib`objc_exception_rethrow + 37
    frame #9: 0x0000000109ef1eea CoreFoundation`CFRunLoopRunSpecific + 570
    frame #10: 0x000000010e7e2bb0 GraphicsServices`GSEventRunModal + 65
    frame #11: 0x0000000117007dd0 UIKitCore`UIApplicationMain + 1621
  * frame #12: 0x0000000103f9812b TheBiggestBlunt`main at AppDelegate.swift:14:7
    frame #13: 0x000000010b94fd29 libdyld.dylib`start + 1

当我在 AppDelegate 类中放置一个断点时,如下所示:


import UIKit
import Firebase
import SwiftKeychainWrapper

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?
    //var actIdc = UIActivityIndicatorView(style: .whiteLarge)
    //lazy var rect = CGRect(x: 10, y: 10, width: 100, height: 100)
    //var container = UIView(frame:rect)

    //var container: UIView = UIView()

    class func instance() -> AppDelegate {
        return UIApplication.shared.delegate as! AppDelegate
    }

//    func showActivityIndicator(){
//        if let window = window{
//            let rect = CGRect(x: 10, y: 10, width: 100, height: 100)
//            container = UIView(frame: rect)
//            //container = UIView()
//            container.frame = window.frame
//            container.center = window.center
//            container.backgroundColor = UIColor(white: 0, alpha: 0.8)
//            actIdc.frame = CGRect(x:0, y:0, width:40, height:40)
//            actIdc.center = CGPoint(x:container.frame.size.width/2,y:container.frame.size.height/2)
//            container.addSubview(actIdc)
//            window.addSubview(container)
//            actIdc.startAnimating()
//        }
//    }

//    func dismissActivityIndicator(){
//        if let _ = window{
//            container.removeFromSuperview()
//        }
//    }

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        FirebaseApp.configure()
        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 invalidate graphics rendering callbacks. 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 active 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:.
    }


}

它转到第一个未注释的行,然后转到汇编代码,然后运行。您会看到登录页面 1 秒钟,然后应用程序会给出一个 SIGABRT。

我检查了所有 IBOutlets,没有任何问题。

有人有这方面的经验吗?

标签: iosswiftxcodefirebase

解决方案


您可能缺少GoogleService-Info.plist需要添加到项目中的文件

在此处输入图像描述


推荐阅读