2017-02-21 71 views
-1

在我的代碼中不斷收到SIGABRT錯誤,我不知道爲什麼。 我覺得我看起來很簡單的錯誤,我似乎無法弄清楚。IBAction在Swift中崩潰

每當我點擊UIButton時,我的應用程序崩潰問題似乎都在IBOutlet中。

的SIGABRT錯誤始於AppDelagate

SignInViewController的開頭:

import UIKit 

import Firebase 
import GoogleSignIn 

@objc(SignInViewController) 
class SignInViewController: UIViewController, GIDSignInUIDelegate { 

    //@IBOutlet weak var signInButton: GIDSignInButton! 

    @IBOutlet weak var signInButton: GIDSignInButton! 

    // @IBOutlet weak var signInButton: GIDSignInButton! 
    var handle: FIRAuthStateDidChangeListenerHandle? 

    override func viewDidLoad() { 
     super.viewDidLoad() 
     GIDSignIn.sharedInstance().uiDelegate = self 
     GIDSignIn.sharedInstance().signInSilently() 
     handle = FIRAuth.auth()?.addStateDidChangeListener() { (auth, user) in 
      if user != nil { 
       MeasurementHelper.sendLoginEvent() 
       self.performSegue(withIdentifier: Constants.Segues.SignInToFp, sender: nil) 
      } 
     } 
    } 

    deinit { 
     if let handle = handle { 
      FIRAuth.auth()?.removeStateDidChangeListener(handle) 
     } 
    } 
} 

Applegate.swift:

import UIKit 
// UserNotifications are only required for the optional FCM step 
import UserNotifications 

import Firebase 
import GoogleSignIn 

@UIApplicationMain 
class AppDelegate: UIResponder, UIApplicationDelegate, GIDSignInDelegate { 

    var window: UIWindow? 

    @available(iOS 9.0, *) 
    func application(_ application: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any]) 
     -> Bool { 
      return self.application(application, open: url, sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication] as? String, annotation: "") 
    } 

    func application(_ application: UIApplication, 
        open url: URL, sourceApplication: String?, annotation: Any) -> Bool { 
     return GIDSignIn.sharedInstance().handle(url, sourceApplication: sourceApplication, annotation: annotation) 
    } 

    func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error?) { 
     if let error = error { 
      print("Error \(error)") 
      return 
     } 

     guard let authentication = user.authentication else { return } 
     let credential = FIRGoogleAuthProvider.credential(withIDToken: authentication.idToken, 
                  accessToken: authentication.accessToken) 
     FIRAuth.auth()?.signIn(with: credential) { (user, error) in 
      if let error = error { 
       print("Error \(error)") 
       return 
      } 
     } 
    } 

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


     FIRApp.configure() 
     GIDSignIn.sharedInstance().clientID = FIRApp.defaultApp()?.options.clientID 
     GIDSignIn.sharedInstance().delegate = self 

     return true 
    } 
} 
+1

你能否提供更多有用的信息,由此我們很難找到源代碼。 – aircraft

+0

哪個UIButton和哪個View Controller按鈕被放置? –

回答

0

這通常是由於未使用IBOutlet。右鍵單擊storyboard中的每個店鋪,然後移除(單擊x)您的viewcontroller中未使用/未參考的任何店鋪。