导致“线程1:信号SIGABRT”的Firebase

我开始了一个空白的Xcode项目,我所做的只是通过Cocoapods添加Firebase框架,并在Appdelegate和viewcontroller中导入。 当我添加FIRApp.configure()didFinishLoadingWithOptions我得到这个错误。 如果我删除该行,但仍然导入框架运行没有错误。 这发生在一个空白的项目中,故事板中也没有,也没有viewcontroller.swift。

在控制台它说libc ++ abi.dylib:终止与typesNSException(11db)的未捕获exception,

Xcode 8.2,swift 3

import UIKit import Firebase @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. FIRApp.configure() return true } func applicationWillResignActive(_ application: UIApplication) { // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. } func applicationDidEnterBackground(_ application: UIApplication) { // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. } func applicationWillEnterForeground(_ application: UIApplication) { // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. } func applicationDidBecomeActive(_ application: UIApplication) { // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. } func applicationWillTerminate(_ application: UIApplication) { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } 

}

Podfile

  # Uncomment the next line to define a global platform for your project # platform :ios, '9.0' target 'dur2' do # Comment the next line if you're not using Swift and don't want to use dynamic frameworks use_frameworks! # Pods for dur2 pod 'Firebase/Core' pod 'Firebase/AdMob' pod 'Firebase/Messaging' pod 'Firebase/Database' pod 'Firebase/Invites' pod 'Firebase/DynamicLinks' pod 'Firebase/Crash' pod 'Firebase/RemoteConfig' pod 'Firebase/Auth' pod 'Firebase/Storage' pod 'SDWebImage' 

结束

我们来试一下吧。

按照Firebase网站上的说明创build一个新项目,确保将GoogleService-Info.plist添加到您的项目中。

在创buildpod文件的步骤中,确保您位于您的项目文件夹中并使用以下文本:

 # Uncomment the next line to define a global platform for your project # platform :ios, '9.0' target 'your-project-name' do # Comment the next line if you're not using Swift and don't want to use dynamic frameworks use_frameworks! # Pods for Firesearch pod 'Firebase/Core' end 

并把你的项目名称代替你的项目名称

保存文件,然后做一个

 pod install 

然后打开project-name.xcworkspace并构build它。

为Xcode 9工作

如果没有解决scheme为你工作,试试这个:

  1. closuresXcode
  2. 在Finder中:

    • 删除.xcworkspace文件
    • 删除Podfile.lock文件
    • 删除Pods文件夹
  3. 在terminal(在项目文件夹中): pod install

  4. 确保GoogleService-Info.plist已添加到您的目标并为您的BUNDLE_ID生成。

当您同时使用“Firebase / Admob”“Firebase / Core”窗格时,Xcode可能会弄乱工作空间并产生一个错误的构build,如果您尝试调用FirebaseApp.configure()GADMobileAds.configure( withApplicationID:“APP_ID”)

如果你还没有,

在firebase中转到您的项目并下载google.plist文件并将其添加到您的项目并运行。