应用程序在登录时崩溃(xcode 9.3)EXC_BAD_ACCESS(代码=1,地址=0x1)

2023-11-24

我在 9.3 更新上遇到此崩溃,在 9.2 上一切正常。会是什么?通过任何来源(登录通行证、VK、谷歌)登录时都会出现该错误

class AppDelegate: UIResponder, UIApplicationDelegate, GIDSignInDelegate {

var window: UIWindow?

private let settingsManager = SettingsManager.manager

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

//  Googole Map
    GMSServices.provideAPIKey("-k")

    UINavigationBar.appearance().tintColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
    UINavigationBar.appearance().barTintColor = #colorLiteral(red: 0.2069905996, green: 0.2386507988, blue: 0.3337202668, alpha: 1)

    UITabBar.appearance().tintColor = #colorLiteral(red: 0.2069905996, green: 0.2386507988, blue: 0.3337202668, alpha: 1)

    let barFont = UIFont.systemFont(ofSize: 20)
    UINavigationBar.appearance().titleTextAttributes =  [NSForegroundColorAttributeName: #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1), NSFontAttributeName: barFont]


    if settingsManager.isFirstStartApp {

    } else {

        settingsManager.isFirstStartApp = true
        settingsManager.setDefaultSettings()

    }

    // Facebook
    FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)

    // Google +
    var configureError: NSError?
    GGLContext.sharedInstance().configureWithError(&configureError)
    assert(configureError == nil, "Error configuring Google services: \(String(describing: configureError)) )")
    GIDSignIn.sharedInstance().delegate = self

    return true
}

通过谷歌签名时,第一种申请方法出错。我搜索了一些主题 - 没有运气。转换到 Swift 4 - 不走运。有任何想法吗?

崩溃日志Pastebin.com/DEEEeQnZB

有了接受的答案,我得到了进一步的帮助,但现在它崩溃了

        let predicate = NSPredicate(format: "isActive == %@", true as CVarArg) 

具有相同的“访问错误”

UPD:问题已通过替换解决

let predicate = NSPredicate(format: "isActive == %@", true as CVarArg)

to

let predicate = NSPredicate(format: "isActive == true")

Facebook 登录也有类似的问题 - 在 Xcode 9.3 发行说明中找到了我的工作:

https://developer.apple.com/library/content/releasenotes/DeveloperTools/RN-Xcode/Chapters/Introduction.html#//apple_ref/doc/uid/TP40001051-CH1-DontLinkElementID_1

引用他们的话

在定义了协议方法或基类方法的情况下 在 Objective-C 中声明在其参数中采用 id 类型的非空参数 标头,但在运行时使用 nil 值调用,Swift 代码 由 Xcode 9.3 编译并覆盖这些方法可能会在以下情况下崩溃: 调用 Swift 实现。 (38675815) 解决方法:更改 Swift 重写以获取 Any? 类型的值。例如,如果您 实现 UIApplicationDelegate 协议 application(_:open:sourceApplication:annotation:) 方法:

class AppDelegate: UIApplicationDelegate {
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
    return true
}

当传递 nil 作为注释参数时,程序可能会崩溃。 通过使注释参数的类型为 Any? 来避免崩溃:

class AppDelegate: UIApplicationDelegate {
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any?) -> Bool {
    return true
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

应用程序在登录时崩溃(xcode 9.3)EXC_BAD_ACCESS(代码=1,地址=0x1) 的相关文章

随机推荐