Steps to Configure Firebase in AppDelegate.m
1. Add GoogleService-Info.plist to Your Project:
•Make sure you have downloaded the GoogleService-Info.plist file from the Firebase console.
2. Download the GoogleService-Info.plist file:
•Go to the Firebase Console, select your project, and download the GoogleService-Info.plist file from the project settings under the iOS app section.
3. Add the GoogleService-Info.plist to Xcode:
•Open your Xcode project.
•Drag and drop the GoogleService-Info.plist file into the root directory of your iOS project in Xcode. Typically, this is at the same level as your AppDelegate files.
•When you drop the file into Xcode, ensure that:
•Copy items if needed is checked.
•It is added to all necessary targets (select your app’s target in the prompt).
4. Verify the File’s Location in Xcode:
•After adding the file, ensure it is correctly linked by going to the “Build Phases” tab of your app target in Xcode.
•Under “Copy Bundle Resources”, confirm that the GoogleService-Info.plist is listed. If it’s missing, you can manually add it here.
5. File Structure:
•The GoogleService-Info.plist should reside at the root level of your Xcode project in the ios folder (not inside any subfolders).
Example file path:
1 |
/YourProject/ios/GoogleService-Info.plist |
6. Modify Your AppDelegate.m File:
•Open the AppDelegate.m file and import Firebase.
• Call FirebaseApp.configure() in the didFinishLaunchingWithOptions method.
Here is the full code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
#import "AppDelegate.h" #import <Firebase.h> // Import Firebase @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Configure Firebase [FIRApp configure]; // Other app initialization code... return [super application:application didFinishLaunchingWithOptions:launchOptions]; } @end |
7. Verify the GoogleService-Info.plist File Path:
•Ensure that GoogleService-Info.plist is correctly linked in Xcode.
•In Xcode, check the “Build Phases” → “Copy Bundle Resources” to make sure GoogleService-Info.plist is included.
Final Step:
•After implementing the above changes, make sure to clean your project and rebuild it:
1 2 3 4 |
cd ios pod install npx react-native run-ios |
This should properly initialize Firebase in your iOS project and resolve the error.