我在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 - 没有运气。有什么想法吗?
接受了接受的答案,我得到了更多,但现在它崩溃了
let predicate = NSPredicate(format: "isActive == %@", true as CVarArg)
具有相同的“访问不良”
UPD:通过替换
来解决问题let predicate = NSPredicate(format: "isActive == %@", true as CVarArg)
到
let predicate = NSPredicate(format: "isActive == true")
答案 0 :(得分:15)
与Facebook登录有类似的问题 - 在Xcode 9.3发行说明中找到了我的工作:
引用它们
在定义协议方法或基类方法的情况下 在Objective-C声称在其中使用类型为id的非null参数 标题,但在运行时使用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
}
答案 1 :(得分:4)
崩溃是因为Xcode 9.3 swift编译改变了ojective -c协议基础方法。因此,如果应用程序中的崩溃在vim
文件中启动,则会更改以下函数
func application(_ application:UIApplication,open url:URL,sourceApplication:String?,annotation:Any) - >布尔{
到
func application(_ application:UIApplication,open url:URL,sourceApplication:String?,annotation:Any?) - >布尔{
所以基本上你必须在AppDelegate.swift
?
注意最重要的一点: - 您还必须从
中删除所有异常Any
答案 2 :(得分:4)
以下更改修复了我的NSPredicate问题。
从:
NSPredicate(format: "%K = %@", #keyPath(PlayerMO.isSelected), true as CVarArg)
为:
NSPredicate(format: "%K = %@", #keyPath(PlayerMO.isSelected), NSNumber(value: true))