Realm在初始化中引发信号SIGABRT

时间:2019-09-09 17:44:26

标签: ios swift realm swift4.2

当我尝试使用Realm时,它只会崩溃,而无论是在AppDelegate中还是在ViewController Realm中将其初始化都不会崩溃。

我试图在每个ViewController中重新安装pod并初始化Realm,还将其从Do-Catch块中删除,但是会引发相同的错误。

import UIKit
import FacebookCore
import GoogleSignIn
import FacebookLogin
import UserNotifications
import CocoaMQTT
import RealmSwift
import Realm

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, GIDSignInDelegate, UNUserNotificationCenterDelegate, CocoaMQTTDelegate {
    var window: UIWindow?
    let notificationCenter = UNUserNotificationCenter.current()
    var mqtt: CocoaMQTT!

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
        do {
            let realm = try Realm()
        } catch {
            print("Error initialising new realm")
        }

        SDKApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions)

        notificationCenter.delegate = self
        GIDSignIn.sharedInstance().clientID = "474109104469-tqkt0nvqnhf0hjvc3a6idsnnhr7susgv.apps.googleusercontent.com"
        GIDSignIn.sharedInstance().serverClientID = "474109104469-tqkt0nvqnhf0hjvc3a6idsnnhr7susgv.apps.googleusercontent.com"
        GIDSignIn.sharedInstance().delegate = self

        SDKApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions)

        registerForPushNotifications()

        return true
    }

这是错误日志:


libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    frame #0: 0x00000001dce320dc libsystem_kernel.dylib`__pthread_kill + 8
    frame #1: 0x00000001dceab094 libsystem_pthread.dylib`pthread_kill$VARIANT$mp + 380
    frame #2: 0x00000001dcd8bea8 libsystem_c.dylib`abort + 140
    frame #3: 0x00000001dc458788 libc++abi.dylib`abort_message + 132
    frame #4: 0x00000001dc458934 libc++abi.dylib`default_terminate_handler() + 308
    frame #5: 0x00000001dc46fe00 libobjc.A.dylib`_objc_terminate() + 124
    frame #6: 0x00000001dc464838 libc++abi.dylib`std::__terminate(void (*)()) + 16
    frame #7: 0x00000001dc464434 libc++abi.dylib`__cxa_rethrow + 144
  * frame #8: 0x00000001039a85ac Realm`::+[RLMSchema sharedSchema](self=RLMSchema, _cmd="sharedSchema") at RLMSchema.mm:270:13
    frame #9: 0x0000000103978f98 Realm`::+[RLMRealm realmWithConfiguration:error:](self=RLMRealm, _cmd="realmWithConfiguration:error:", configuration=0x000000010520bd50, error=0x000000016dceb620) at RLMRealm.mm:492:69
    frame #10: 0x0000000104da947c RealmSwift`@nonobjc RLMRealm.__allocating_init(configuration:) at <compiler-generated>:0
    frame #11: 0x0000000104da932c RealmSwift`Realm.__allocating_init() at Realm.swift:67:28
    frame #12: 0x000000010238c4cc Lya`AppDelegate.init() at AppDelegate.swift:22:22
    frame #13: 0x000000010238c688 Lya`@objc AppDelegate.init() at <compiler-generated>:0
    frame #14: 0x0000000209a58088 UIKitCore`_UIApplicationMainPreparations + 1720
    frame #15: 0x0000000209a57944 UIKitCore`UIApplicationMain + 160
    frame #16: 0x000000010238c910 Lya`main at AppDelegate.swift:19:7
    frame #17: 0x00000001dcce68e0 libdyld.dylib`start + 4

这是Podfile:

target 'Project' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

  # Pods for Lya
  pod 'FacebookCore'
  pod 'FacebookLogin'
  pod 'FacebookShare'
  pod 'GoogleSignIn'
  pod 'CocoaMQTT'
  pod 'Alamofire'
  pod 'SwiftyJSON', '~> 4.0'
  pod 'BCryptSwift'
  pod 'RealmSwift'

end

0 个答案:

没有答案