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.
In the console it says libc++abi.dylib: terminating with uncaught exception of type NSException
(11db)
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
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.
At the step where you create a pod file, make sure you are in your projects folder and use this text:
# 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.
Worked for 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
In Terminal (in project folder): pod install
Make sure that GoogleService-Info.plist is added to your target and generated for your 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")
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.
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.)
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
Instead of copying GoogleService-Info.plist to your project, just drag and drop GoogleService-Info.plist to ios/appName, then check the copy if needed option.
For Swift 4 and 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.
Related
I was trying to test Admob ads. However, it's getting an exception before the app starts
'GADInvalidInitializationException', reason: 'The Google Mobile Ads SDK was initialized without AppMeasurement.
However, I have added the AppID and cocoapod
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
podfile
target 'My App' do
use_frameworks!
pod 'Google-Mobile-Ads-SDK'
end
Info.list
<key>GADApplicationIdentifier</key>
<string>ca-app-pub-3940256099942544~1458002511</string>
AppDelegate.swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Initialize Google Mobile Ads SDK
GADMobileAds.sharedInstance().start(completionHandler: nil)
return true
}
Have anyone faced this issue? Thanks in Advance.
In case anyone else is facing the problem, I am answering my own question.
According to the documentation, this step is in manual download. However, that is a mandatory step to do even if you are using cocoapod.
Firstly, I would like to let you know that I have user Firebase Firestore several times before and have not faced such an error... I have followed the process correctly step by step and, because it was not working, I also tried to add firebase to an existing project and it has still given me errors. Below is there error which I get :
2020-05-21 09:32:15.775788+0530 Job App[61230:1180572] [GoogleDataTransport][I-GDTCOR001006] (/Users/tejas/Desktop/Files/Coding/Main Projects/Job App/Pods/GoogleDataTransport/GoogleDataTransport/GDTCORLibrary/GDTCOREvent.m:59) : There was an error saving the new counter value to disk.
Keep in mind that this error only pops up the first time I run the app on the simulator, then when I rerun it this error is gone. My app also doesn't even crash and the build always succeeds despite this error. Here is my app information:
Here is the code in my app delegate
import Firebase
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool
{
// Override point for customization after application launch.
FirebaseApp.configure()
return true
}
My GoogleService-Info.plist file has the correct bundle ID :
Here is the file inspector of my GoogleService-Info.plist:
Here is the code inside my podfile:
# Uncomment the next line to define a global platform for your project
platform :ios, '13.0'
target 'Job App' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for Job App
pod 'lottie-ios'
pod 'Firebase/Firestore'
end
Here is the message I get from the Firebase App Setup Wizard :
These are the pods under the pods folder :
It keeps on loading for a very long time and I'm sure that something is going wrong...
Do pod update and make sure that the GoogleDataTransport pod is at version 6.1.1.
This issue was fixed a few weeks ago. See https://github.com/firebase/firebase-ios-sdk/issues/5421
I am trying to create a few common functions that read and write to Firestore in an Xcode framework so that they can be shared across a few a different apps. But the app crashes with
The default FIRApp instance must be configured before the default
FIRAuthinstance can be initialized. One way to ensure that is to call
[FIRApp configure]; (FirebaseApp.configure() in Swift) in the App
Delegate's application:didFinishLaunchingWithOptions:
(application(_:didFinishLaunchingWithOptions:) in Swift).'
I am configuring Firebase in the main app with FirebaseApp.configure(). As soon as I move the file off the framework, the crash goes away. Is this expected to work?
Other details that might be relevant.
Xcode 11.2.1
Deployment target iOS 13.0
It looks like it is safe to call FirebaseApp.configure() from within your iOS framework (as long as you only call it once per framework). For example, create a static method inside a framework's class:
open class MyFramework {
public static func configure() {
FirebaseApp.configure()
}
}
Then call it from your App Delegate:
class AppDelegate ... {
func application(_ application: UIApplication, didFinishLaunching...) {
FirebaseApp.configure()
MyFramework.configure()
}
}
When a crash gets uploaded to the firebase dashboard it always shows the message Upload symbol file to symbolicate future stack traces for UUID *******. However I did make sure that the symbol files got uploaded by looking in the Symbol Files tab. Something I noticed though was that the symbol files had a different UUID then what the message on the crash said. What might I be doing wrong here?
Something strange is that it seems like neither the UUID in uploaded symbol files nor in the message mentioned above is correct. I get a third UUID when I check it up locally by following this guide (basically running find . -iname *.app in ~/Library/Developer/CoreSimulator/Devices/).
I first got this issue in our app using swift 2 and xcode 7. However I also gets the same issue using a new firebase app (ios sdk v3.8) and a minimal xcode 8 project with swift 3 that is setup exactly as advised in the docs.
// AppDelegate.swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FIRApp.configure()
return true
}
// ViewController.swift
override func viewDidLoad() {
super.viewDidLoad()
FIRCrashMessage("A test message")
fatalError()
}
// Run script in Build Phases that uploads symbol files
GOOGLE_APP_ID=our_google_app_id
"${PODS_ROOT}"/FirebaseCrash/upload-sym "serviceaccount.json"
// Podfile (using latest versions as of 2017-05-12, v3.17.0)
pod 'Firebase/Core'
pod 'Firebase/Crash'
I think maybe the path of "ServiceAccount.json" is wrong, please check again. It should be
"${PODS_ROOT}"/FirebaseCrash/upload-sym "/Path/To/ServiceAccount.json"
And you need also to add this in the script.
rm $HOME/Library/Preferences/com.google.SymbolUpload*
All I can find is Is there a quick way to force a crash? which says to:
[[Crashlytics sharedInstance] crash];
which I think in Swift would be
Crashlytics.sharedInstance.crash()
but this does not seem to exist. (perhaps the docs are out of date and no longer apply since Fabric gobbled up Crashlytics?)
I see that there is a Crashlytics.crash(self:Crashlytics) ...nevermind, friggin XCode's completion is always broken for me. See answer below.
If you are using the new Firebase Crashlytics SDK note that import Crashlytics has been replaced by import FirebaseCrashlytics. The crash() method is no longer available in the new SDK. As recommended by Firebase, simply use:
Swift:
fatalError()
Obj C:
assert(NO);
(if it's in a file other than your AppDelegate, you will need to import Crashlytics, then just do Crashlytics.sharedInstance().crash()
Create a Project and App in firebase
Add a new iOS app in the firebase console if you have existing firebase project or create firebase project and create new app in the firebase console.
Add Firebase to iOS App
Firstly in step 1, register your app by adding the bundle identifier while creating iOS app to firebase. In step 2, Download config file GoogleService-Info.plist add it to your workspace like in the image shown below.
Add Crashlytics SDK via CocoaPods
To get started, add the Crashlytics SDK framework files to your project. For most projects, the easiest way to do that is by adding the Crashlytics CocoaPods.
pod 'Firebase/Core'
pod 'Fabric', '~> 1.7.2'
pod 'Crashlytics', '~> 3.9.3'
Test your implementation
Enable Crashlytics debug mode: In order to enable crashlytics in debug mode we need to set Fabric.sharedSDK().debug mode to true in AppDelegate.swift.
import UIKit
import Firebase
import Crashlytics
import Fabric
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
Fabric.sharedSDK().debug = true
return true
}
Force crash to test implementation: While writing this article, I have one view controller with one button named (Click to crash app) in the middle of the viewController. For the testing purpose, when user click the button app crashed.
And View controller this below code and run once in simulator or device and check in Firebase dashboard .You find all crashes report.
import UIKit
import Crashlytics
class ViewController: UIViewController {
var name:String!
var number:Int!
override func viewDidLoad() {
super.viewDidLoad()
name = "12"
}
#IBAction func crashBtnAction(_ sender: Any) {
//creshreportMethod()
print("name of the value",name)
var myDict = [String:Any]()
myDict = ["name":number!]
print("my dict value",myDict)
}
}
Crashlytics can’t capture crashes if your build attaches a debugger at launch. Adjust your build settings to change the project’s debug information format:
With your project still selected in the Xcode Navigator, open the Build Settings tab.
Click All at the top of the tab to display all build settings.
Search for “debug information format”.
Set the Debug Information Format setting to DWARF with dSYM File.