I have set up multiple Firebase environments that allow me to point to different Firebase projects when the app is launched in DEBUG or RELEASE configuration. I do not follow the Firebase documentation due to potential analytics issues indicated, so I implemented it using the method in this Medium post. All is good for the main app target.
Now, I am attempting to implement the same for my Widget Extension and Intents, but my widgets always crash with:
*** Terminating app due to uncaught exception 'com.firebase.core', reason: '
FirebaseApp.configure()could not find a valid GoogleService-Info.plist in your project. Please download one from https://console.firebase.google.com/.'
I duplicated the steps in the Medium post for the Widgets and Intents, ie:
- Downloaded the GoogleService-Info.plist for both prd and dev environments, and created the directories in the Widgets and Intents targets. I also ensured they are not added to targets and unchecked "Copy items if needed" according to the post.
- Added the Run Scripts to both Widgets and Intents targets respectively, and ensured they are before "Copy Bundle Resources".
Code that I use to initialize Firebase in the Widgets as suggested in this SO post:
import Firebase
struct MyWidget: Widget {
let kind: String = "MyWidgetKind"
init() {
FirebaseApp.configure()
}
var body: some WidgetConfiguration {
IntentConfiguration(kind: kind, intent: MyIntent.self, provider: Provider()) { entry in
MyEntryView(entry: entry)
}
.configurationDisplayName("Lorem ipsum")
.description("Lorem ipsum")
}
}