xcode Firebase 导致“线程 1:信号 SIGABRT”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41325082/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Firebase causing "Thread 1: signal SIGABRT"
提问by Henry
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 didFinishLoadingWithOptionsI 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: terminating with uncaught exception of type NSException (11db)
Xcode 8.2, swift 3
Xcode 8.2,快速 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
结尾
采纳答案by Jay
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 文件的步骤中,确保您位于项目文件夹中并使用以下文本:
# 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 并构建它。
回答by serg_zhd
Worked for Xcode 9
适用于 Xcode 9
If none of solutions worked for you try this:
如果没有任何解决方案适合您,请尝试以下操作:
- Close Xcode
In Finder:
- Remove .xcworkspacefile
- Remove Podfile.lockfile
- Remove Podsfolder
In Terminal (in project folder): pod install
Make sure that GoogleService-Info.plistis added to your target and generated for your BUNDLE_ID.
- 关闭 Xcode
在查找器中:
- 删除.xcworkspace文件
- 删除Podfile.lock文件
- 删除Pods文件夹
在终端(在项目文件夹中):pod install
确保将GoogleService-Info.plist添加到您的目标并为您的 BUNDLE_ID 生成。
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”pod 时,Xcode 可能会弄乱工作区并产生错误的构建,如果您尝试调用FirebaseApp.configure()或GADMobileAds.configure( withApplicationID: "APP_ID")
回答by Ro4ch
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 文件并将其添加到您的项目中并运行。
回答by arsalan_h
I had the same problem and I solved it by using another gmail account. Create a new project on firebase then create a data base and add your ios app to the firebase database (Make sure that GoogleService-Info.plist is added to your target and generated for your BUNDLE_ID.)
我遇到了同样的问题,我使用另一个 gmail 帐户解决了它。在 firebase 上创建一个新项目,然后创建一个数据库并将您的 ios 应用程序添加到 firebase 数据库(确保将 GoogleService-Info.plist 添加到您的目标并为您的 BUNDLE_ID 生成。)
回答by alpha911
I've been pulling my hair for 2 days...
我拉了两天的头发...
here is what I found
这是我发现的
- make sure you have the right GoogleService-info.plist file enable the .plist file.
- point the file to your target app plist target to your app
- 确保您拥有正确的 GoogleService-info.plist 文件以启用 .plist 文件。
- 将文件指向您的目标应用程序 plist 目标指向您的应用程序
回答by CharlieOxendine
For Swift 4 and Xcode 10:
对于 Swift 4 和 Xcode 10:
Delete the XC workspace, podfile.lock, podfile and the pod folder. Then re-do the pod install and start with your new XC workspace.
删除 XC 工作区、podfile.lock、podfile 和 pod 文件夹。然后重新安装 pod 并从新的 XC 工作区开始。
回答by RANVIR GORAI
Instead of copying GoogleService-Info.plistto your project, just drag and drop GoogleService-Info.plistto ios/appName, then check the copy if needed option.
无需将GoogleService-Info.plist复制到您的项目,只需将GoogleService-Info.plist拖放到 ios/appName,然后根据需要检查复制选项。