2017-02-21 8 views
-1

Продолжайте получать ошибку SIGABRT в моем коде, и я не знаю почему. Я чувствую, что я нахожусь на очень простой ошибке, и я просто не могу понять, как это понять.IBAction Crashing in 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.