I started a blank Xcode project and all I did was add the Firebase framework via Cocoapods and import in the Appdelegate and viewcontroller. When I add FIRApp.configure() to didFinishLoadingWithOptions I get that error. If I remove that line but still have the framework imported it runs with no errors. This happens on a blank project with nothing in the storyboard nor viewcontroller.swift.
我开始了一个空白的Xcode项目,我所做的就是通过Cocoapods添加Firebase框架并在Appdelegate和viewcontroller中导入。当我将FIRApp.configure()添加到didFinishLoadingWithOptions时,我得到了这个错误。如果我删除该行但仍导入框架,则运行时没有错误。这发生在一个空白项目中,故事板中没有任何内容,也没有viewcontroller.swift。
In the console it says libc++abi.dylib: terminating with uncaught exception of type NSException (11db)
在控制台中它说libc ++ abi.dylib:以NSException类型的未捕获异常终止(11db)
Xcode 8.2, swift 3
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'
end
3 个解决方案
#1
3
Let's try a test.
我们来试试吧。
Create a new project following the instructions on the Firebase website, ensuring you add the GoogleService-Info.plist to your project.
按照Firebase网站上的说明创建一个新项目,确保将GoogleService-Info.plist添加到您的项目中。
At the step where you create a pod file, make sure you are in your projects folder and use this text:
在创建pod文件的步骤中,确保您位于projects文件夹中并使用以下文本:
# 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
and put your project name in place of your-project-name
并将您的项目名称替换为您的项目名称
Save the file and then do a
保存文件,然后执行
pod install
Then open the project-name.xcworkspace and build it.
然后打开project-name.xcworkspace并构建它。
#2
2
Worked for Xcode 9
为Xcode 9工作
If none of solutions worked for you try this:
如果没有一个解决方案适合您,请尝试这样做
- Close Xcode
-
In Finder:
- Remove .xcworkspace file
- Remove Podfile.lock file
- Remove Pods folder
删除.xcworkspace文件
删除Podfile.lock文件
删除Pods文件夹
-
In Terminal (in project folder): pod install
在终端(在项目文件夹中):pod安装
-
Make sure that GoogleService-Info.plist is added to your target and generated for your BUNDLE_ID.
确保将GoogleService-Info.plist添加到您的目标并为您的BUNDLE_ID生成。
在Finder中:删除.xcworkspace文件删除Podfile.lock文件删除Pods文件夹
For unknown reasons when you use both "Firebase/Admob" and "Firebase/Core" pods Xcode can mess up the workspace and produce a bad build that will crash at runtime if you try to call FirebaseApp.configure() or GADMobileAds.configure(withApplicationID: "APP_ID")
当您同时使用“Firebase / Admob”和“Firebase / Core”窗格时,由于未知原因,如果您尝试调用FirebaseApp.configure()或GADMobileAds.configure,Xcode会导致工作区混乱并产生错误的构建,该构建将在运行时崩溃( withApplicationID:“APP_ID”)
#3
1
If you haven't yet,
如果还没有,
Go to your project in firebase and download the google.plist file and add it to your project and run.
转到firebase中的项目并下载google.plist文件并将其添加到项目中并运行。
#1
3
Let's try a test.
我们来试试吧。
Create a new project following the instructions on the Firebase website, ensuring you add the GoogleService-Info.plist to your project.
按照Firebase网站上的说明创建一个新项目,确保将GoogleService-Info.plist添加到您的项目中。
At the step where you create a pod file, make sure you are in your projects folder and use this text:
在创建pod文件的步骤中,确保您位于projects文件夹中并使用以下文本:
# 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
and put your project name in place of your-project-name
并将您的项目名称替换为您的项目名称
Save the file and then do a
保存文件,然后执行
pod install
Then open the project-name.xcworkspace and build it.
然后打开project-name.xcworkspace并构建它。
#2
2
Worked for Xcode 9
为Xcode 9工作
If none of solutions worked for you try this:
如果没有一个解决方案适合您,请尝试这样做
- Close Xcode
-
In Finder:
- Remove .xcworkspace file
- Remove Podfile.lock file
- Remove Pods folder
删除.xcworkspace文件
删除Podfile.lock文件
删除Pods文件夹
-
In Terminal (in project folder): pod install
在终端(在项目文件夹中):pod安装
-
Make sure that GoogleService-Info.plist is added to your target and generated for your BUNDLE_ID.
确保将GoogleService-Info.plist添加到您的目标并为您的BUNDLE_ID生成。
在Finder中:删除.xcworkspace文件删除Podfile.lock文件删除Pods文件夹
For unknown reasons when you use both "Firebase/Admob" and "Firebase/Core" pods Xcode can mess up the workspace and produce a bad build that will crash at runtime if you try to call FirebaseApp.configure() or GADMobileAds.configure(withApplicationID: "APP_ID")
当您同时使用“Firebase / Admob”和“Firebase / Core”窗格时,由于未知原因,如果您尝试调用FirebaseApp.configure()或GADMobileAds.configure,Xcode会导致工作区混乱并产生错误的构建,该构建将在运行时崩溃( withApplicationID:“APP_ID”)
#3
1
If you haven't yet,
如果还没有,
Go to your project in firebase and download the google.plist file and add it to your project and run.
转到firebase中的项目并下载google.plist文件并将其添加到项目中并运行。