firebase-ios-sdk: crash in +[FRepoManager createRepo:config:database:] stemming from initializing Database.database()
Environment
- Xcode version: 8.3.2
- Firebase SDK version: 4.0.0
- Library version: unsure what Library is
- Firebase Product: database
[REQUIRED] Step 3: Describe the problem
Steps to reproduce:
Crash in +[FRepoManager createRepo:config:database:]. Here’s the relevant part of the stack trace:
0 CoreFoundation 0x000000010b386b0b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x0000000109f55141 objc_exception_throw + 48
2 CoreFoundation 0x000000010b2a16e2 -[__NSDictionaryM setObject:forKey:] + 1042
3 wrytr 0x00000001088d7f83 +[FRepoManager createRepo:config:database:] + 404
4 wrytr 0x00000001088bed22 -[FIRDatabase ensureRepo] + 151
5 wrytr 0x00000001088be3eb -[FIRDatabase reference] + 31
6 wrytr 0x0000000108854471 _TFCC5wrytr8Firebase8ProvidercfT_S1_ + 97
It seems to be related to https://github.com/firebase/quickstart-ios/issues/261, but the fix provided there (be on the main thread) doesn’t apply to me, as my code is executing on Thread 1:

I know the crash is happening somewhere inside a dictionary set in this method in FRepoManager, but I’m not sure why
Relevant Code:
https://github.com/AndrewSB/wrytr/blob/master/Common/API/FirebaseProvider.swift#L13
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 25 (24 by maintainers)
Commits related to this issue
- fix Firebase.Database crash on launch see https://github.com/firebase/firebase-ios-sdk/issues/31 — committed to AndrewSB/wrytr by AndrewSB 7 years ago
- mark FIRDatabase init unavailable (#48) FIRDatabase's initializer is inherited from NSObject and causes subtle bugs if called. See https://github.com/firebase/firebase-ios-sdk/issues/31 — committed to firebase/firebase-ios-sdk by AndrewSB 7 years ago
- mark FIRDatabase init unavailable (#48) FIRDatabase's initializer is inherited from NSObject and causes subtle bugs if called. See https://github.com/firebase/firebase-ios-sdk/issues/31 — committed to minafarid/firebase-ios-sdk by AndrewSB 7 years ago
Just FYI- I think thread 3 is actually analytics, not Database. Confusingly FIRADatabase is an analytics class, unlike FIRDatabase. 😃
Also, can you try logging FirebaseApp.app().name ? If it’s somehow nil, I think that could cause that exception.