Or, without adding an additional application to the Firebase console, just reuse your main GoogleService-Info.plist project with minor changes (see below). A singleton Firebase application must be configured in both cases at startup.
To synchronize the extension and the containing application, see Application Extension Programming Guide: Handling Common Scripts or this Reddit comment . fooobar.com/questions/2433675 / ... specifically describes this scenario.
Steps :
- Copy the containing
GoogleService-Info.plist application to your extension in Xcode - Drag the copied
GoogleService-Info.plist into Xcode into the extension of your GoogleService-Info.plist resource and - Change BUNDLE_ID to the name of your share extension target.
- Add a new target to your
Podfile - Install dependencies (
pod install ) - Configure the Firebase application object in your extension
Step 1. Copy the containing GoogleService-Info.plist application to your extension in Xcode
Step 2. Drag the copied GoogleService-Info.plist into Xcode into the extension of your GoogleService-Info.plist resource and
Step 3. Change BUNDLE_ID to the name of your share extension target.
For us, the main (that is, containing the application) is Access News and the Access-News-Uploader extension is Access-News-Uploader .


Step 4. Add a new target to your Podfile
# ... target 'name-of-your-extension' do use_frameworks! pod 'Firebase/Core' pod 'Firebase/Auth'
The whole Podfile our project .
Step 5. Install the dependencies ( pod install )
Step 6. Configure the Firebase application object in your extension
/* 1. Import Firebase */ /**********************/ import Firebase /**********************/ class WhereverInYourExtension: WhateverController { // ... override func viewDidLoad() { super.viewDidLoad() /* 2. Configure Firebase */ /*************************/ if FirebaseApp.app() == nil { FirebaseApp.configure() } /*************************/ // ... }
Bugs fixed
1) Still can not import Firebase!
Make sure the modules are installed for all purposes in your project. To achieve this, use inherit! or abstract_target in your Podfile.
The simplest example of using abstract_target from the official documentation :
abstract_target 'Networking' do pod 'AlamoFire' target 'Networking App 1' target 'Networking App 2' end
For inherit! See this SO question and answer .
2) How can I achieve this in my existing application without getting confused?
Delete Podfile , Podfile.lock and YourProject.xcworkspace
Run pod init and it will list your existing goals one by one.
Edit the Podfile by grouping under abstract_target or using inherit!
pod install release
There will be YourProject.xcworkspace new YourProject.xcworkspace file, and if you open your project using this, in the " General >" section of Linked Frameworks and Libraries it will show that Firebase has been added and can be imported from project files.
(See this SO thread for a specific example where this cleanup method should have been used.)
3) firebase 'sharedApplication' is unavailable: not available on iOS (App Extension) - Use view controller based solutions where appropriate instead.
Here is what worked for me:
wiped everything clean by cloning the repo of our project with Github,
remote
- ~ / Library / Developer / Xcode / DerivedData
- . / Pods /
- Podfile
- Podfile.lock
Issue pod init on the console
Recreate Podfile (mostly copy-paste)
Release pod update on console
(Probably will not work next time.)