Could not locate configuration file GoogleService-Info.plist when using FirebaseApp.configure(options:)

In my project I have different targets for the same app with different configurations (Production / Staging / QA). As suggested by the Firebase docs I added a plist file for each trarget and initializing FirebaseApp by passing the correct configuration file in this way:

let configPath = Bundle.main.path(forResource: NAME_OF_PLIST_FOR_CURRENT_TARGET ofType: ".plist")! let options = FirebaseOptions(contentsOfFile: configPath)! FirebaseApp.configure(options: options) 

I also removed from my project the GoogleService-Info.plist file as suggested in docs here to ensure reliable Analytics reports.

When I run the app in the console I see these messages.

[Firebase/Core][I-COR000012] Could not locate configuration file: 'GoogleService-Info.plist'. [Firebase/Analytics][I-ACS020006] Google App ID from GoogleService-Info.plist is empty. Please, define GOOGLE_APP_ID in GoogleService-Info.plist for Analytics to work reliably. See [Firebase/Analytics][I-ACS025020] Analytics requires Google App ID from GoogleService-Info.plist. Your data may be lost. Google App ID has been changed. Original, new ID: (nil), MYAPPID 

Am I doing something wrong? Could this configuration lead to lost Analytics? (as console message suggest)

5

5 Answers

When you use flutter:

I ran the flutter cli to add Firebase to my project, using the flutterfire configure command. This added the GoogleService_Info.plist to my project, but didn't register the file in the .xcworkspace file.

So I had to right-click on the Runner-folder in Xcode, choose Add Files to "Runner"..., and select the file GoogleService_Info.plist

After several attempts it seemed that, despite the error messages in the console, Firebase was configured correctly.

Nonetheless I decided to adopt the solution proposed by @Micgal, thus having multiple files named GoogleService-Info.plist in separate filesystem directories and adding each one to the corresponding target. I can then initialize Firebase with FirebaseApp.configure() which works as expected without generating error messages.

Alternative workaround to having separate folders for GoogleService-Info.plist is adding additional step in Build Phases, to copy appropriate file. Just go to Targets / Build Phases and add new script by clicking on "New Run Script Phase". Script could be something like:

cp "${SRCROOT}/${PROJECT}/${FIREBASE_CONFIG_FILE}.plist" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/GoogleService-Info.plist" 

where FIREBASE_CONFIG_FILE is defined in Build Settings as User-Defined settings which has different values for various configurations. And then just calling FirebaseApp.configure().

There is also a dedicated ticket on Firebase github

Build Phases

0

maybe you have to add this needed file (GoogleService-Info.plist) to you project ressources. Open yourproject.xcworkspace in Xcode and in the Project navigator click right on Ressources folder and select 'Add files to...'.

Select the GoogleService-Info.plist in the left pane, then uncheck/recheck the Target Membership checkbox for your project.

Right panel target membership

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like