我在AppDelegate文件中生成错误,这是一个错误。我已经阅读了有关sigabrt的许多其他线程,但是我想问如何解决此sigabrt错误,因为该错误与Google登录有关。
ViewController.swift代码:
import UIKit
import GoogleSignIn
import Firebase
class ViewController: UIViewController, GIDSignInUIDelegate {
override func viewDidLoad() {
super.viewDidLoad()
setupGoogleButtons()
}
fileprivate func setupGoogleButtons(){
//default google sign in button
let googleButton = GIDSignInButton()
googleButton.frame = CGRect(x: 16, y: 116 + 80, width: view.frame.width - 32, height: 50)
view.addSubview(googleButton)
//custom google sign in button
let customButton = UIButton(type: .system)
customButton.frame = CGRect(x: 16, y: 116 + 80 + 66, width: view.frame.width - 32, height: 50)
customButton.backgroundColor = .blue
customButton.setTitleColor(.white, for: .normal)
customButton.titleLabel?.font = UIFont.boldSystemFont(ofSize: 14)
customButton.setTitle("Google Sign In #2", for: .normal)
customButton.addTarget(self, action: #selector(handleCustomGoogleSignIn), for: .touchUpInside)
view.addSubview(customButton)
}
func handleCustomGoogleSignIn() {
GIDSignIn.sharedInstance().signIn()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
AppDelegate文件代码:
import UIKit
import Firebase
import GoogleSignIn
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, GIDSignInDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FIRApp.configure()
GIDSignIn.sharedInstance().clientID = FIRApp.defaultApp()?.options.clientID
GIDSignIn.sharedInstance().delegate = self
return true
}
func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) {
if let err = error {
print("Failed to log into Google: ", err)
return
}
print("Successfully logged into Google", user)
guard let idToken = user.authentication.idToken else { return }
guard let accessToken = user.authentication.accessToken else { return }
let credentials = FIRGoogleAuthProvider.credential(withIDToken: idToken, accessToken: accessToken)
FIRAuth.auth()?.signIn(with: credentials, completion: { (user, error) in
if let err = error {
print("Failed to create a Firebase User with Google account: ", err)
return
}
guard let uid = user?.uid else { return }
print("Successfully logged into Firebase with Google", uid)
})
}
func application(_ application: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey: Any] = [:]) -> Bool {
GIDSignIn.sharedInstance().handle(url,
sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication] as? String,
annotation: options[UIApplicationOpenURLOptionsKey.annotation])
return true
}
}
控制台错误消息:
objc [12677]:PLBuildVersion类在/Users/tarunaarora/Downloads/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/AssetsLibraryServices中均已实现。框架/ AssetsLibraryServices(0x119012998)和/Users/tarunaarora/Downloads/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/PhotoLibraryServices.framework 0x118e34880)。将使用两者之一。哪一个是未定义的。 2016-11-21 21:44:27.647 GunnOracleGoogleSignIn [12677:470666] Firebase自动屏幕报告已启用。调用+ [FIRAnalytics setScreenName:setScreenClass:]设置屏幕名称或覆盖默认屏幕类名称。若要禁用自动屏幕报告,请将Info.plist 2016-11-21 21:44:27.929中的标志FirebaseAutomaticScreenReportingEnabled设置为NO :<FIRInstanceID / WARNING> FIRInstanceID AppDelegate代理已启用,将使应用程序委托远程通知处理程序陷入混乱。若要禁用,请在您的Info.plist中添加“ FirebaseAppDelegateProxyEnabled”,并将其设置为NO 2016-11-21 21:44:27.928 GunnOracleGoogleSignIn [12677] <Debug> [Firebase / Core] [I-COR000001]配置默认应用程序。 2016-11-21 21:44:28.330 GunnOracleGoogleSignIn [12677:] <FIRAnalytics / INFO> Firebase Analytics v。 2016-11-21 21:44:28.542 GunnOracleGoogleSignIn [12677:] <FIRAnalytics / INFO>要启用调试日志记录,请设置以下应用程序参数:-FIRAnalyticsDebugEnabled(请参阅(google url //由于它是goo.gl而无法显示)) ) 2016-11-21 21:44:28.637 GunnOracleGoogleSignSign [12677:] <FIRAnalytics / INFO>成功自动自动创建了Firebase Analytics App委托代理。要禁用代理,请在Info.plist 2016-11-21 21:44:28.782 GunnOracleGoogleSignIn [12677] <Debug> [Firebase / Core] [I-COR000019]清除帖子完成后将标志FirebaseAppDelegateProxyEnabled设置为NO 。 2016-11-21 21:44:30.143 GunnOracleGoogleSignIn [12677:] <FIRAnalytics / WARNING> AdSupport框架当前未链接。某些功能将无法正常运行。了解更多信息(无法显示goo.gl网址) 2016-11-21 21:44:31.086 GunnOracleGoogleSignIn [12677:] <FIRAnalytics / INFO>启用了Firebase Analytics 2016-11-21 21:44:31.841 GunnOracleGoogleSignIn [12677:470666] ***由于未捕获的异常'NSInvalidArgumentException而终止了应用程序',原因:“ uiDelegate必须是| UIViewController | 或实现| signIn:presentViewController:| 和| signIn:dismissViewController:| | GIDSignInUIDelegate |中的方法。 ***第一次抛出调用堆栈: ( 0 CoreFoundation 0x00000001076ffd4b __exceptionPreprocess + 171 1 libobjc.A.dylib 0x000000010716121e objc_exception_throw + 48 2 CoreFoundation 0x00000001077692b5 + [NSException提高:格式:] + 197 3 GunnOracleGoogleSignIn 0x000000010619df7e-[GIDSignIn signInWithOptions:] + 88 9 UIKit 0x00000001082a5d5d-[UIWindow _sendTouchesForEvent:] + 2747 4 GunnOracleGoogleSignIn 0x00000001061a1c13-[按下GIDSignInButton] + 242 5 UIKit 0x000000010823845c-[UIApplication sendAction:to:from:forEvent:] + 83 6 UIKit 0x00000001083be344-[UIControl sendAction:to:forEvent:] + 67 7 UIKit 0x00000001083be65s-[UIControl_Control withEvent:] + 444 8 UIKit 0x00000001083bd559-[UIControl touchedEnded:withEvent:] + 668 11 UIKit 0x000000010825454b-[UIApplication sendEvent:] + 371 10 UIKit的0x00000001082a744b - [一个UIWindow的SendEvent:] + 4011 12的UIKit 0x0000000108a3fa0f __dispatchPreprocessedEventFromEventQueue + 3248 13的UIKit 0x0000000108a38745 __handleEventQueue + 4879 14的CoreFoundation 0x00000001076a48e1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 15的CoreFoundation 0x0000000107689b0c __CFRunLoopDoSources0 + 556 16的CoreFoundation 0x0000000107688ff6 __CFRunLoopRun + 918 17的CoreFoundation 0x0000000107688a04 CFRunLoopRunSpecific + 420 18 GraphicsServices 0x000000010bad6a6f GSEventRunModal + 161 19的UIKit 0x0000000108236808 UIApplicationMain + 159 20 GunnOracleGoogleSignIn 0x00000001060f669f主+ 111 21 libdyld.dylib 0x000000010a4a368d开始+ 1 22 ??? 0x0000000000000001 0x0 +1 ) libc ++ abi.dylib:以类型为NSException的未捕获异常终止
让我知道是否还有其他需要包含的内容。
就我而言,原因是此错误:
Unable to correctly configure subspec Analytics
可以通过将正确的跟踪ID设置为来解决此问题GoogleService-Info.plist
。查看更多信息:由于Firebase初始化,App Delegate崩溃
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句