Matt S.
Matt S.

Reputation: 75

Moving Firebase (GoogleService-Info.plist & API Key) to Production on iOS App Store?

My question revolves around how to transition the information in the GoogleService-Info.plist file to Production (i.e. deployed on the iOS App Store)?

My predicament is pretty simple: I am developing a native iOS app in Swift. I am using Firebase ML Kit (Google Cloud Vision API). When I first set up my project in Firebase, I was prompted to download the GoogleService-Info.plist file, which I did. It is on the Desktop on my local computer, and all my local development works fine.

But, now I am ready to deploy this app to the App Store. Obviously, the App Store app is not going to fetch the credentials from my local Desktop. I am confused on how to transition my credentials to Production. I have read all of the Google Cloud docs (Securing API Keys, Service Accounts, etc.) but I have not found a simple, well-explained solution on how to approach this. If you are able to explain this to me as opposed to link to one of these resources that would be incredibly helpful. Thank you very much.

Upvotes: 3

Views: 2000

Answers (2)

Nasir
Nasir

Reputation: 1727

I had a similar situation where I needed to use separate Firebase projects for dev & prod environments, and like you, I didn’t want to expose sensitive credentials on GitHub.

Here’s how I solved it using iOS .xcconfig files:

  1. I added the necessary keys from GoogleService-Info.plist into a Config_dev.xcconfig file.
  2. Double-checked that Xcode is set to reference the correct .xcconfig file in the project settings.
  3. Linked the keys from the .xcconfig file in the Info.plist file.
  4. Programmatically fetched the keys and values from the Info.plist.
  5. Manually configured Firebase using FirebaseApp.configure(with: options).

This way, I was able to keep my credentials secure and still manage different environments easily.

Here you can find detailed blog

Added keys from GoogleService-Info.plist file

Reference .xcconfig file in Xcode project setting

Reference keys from .xcconfig file in Info.plist file

Upvotes: 0

Logunath
Logunath

Reputation: 477

So, already you have a iOS project configured for GCV API. If the FCM development account and production account are same, the GoogleInfoServiceInfo.plist going to be same. So no worries. You can move to production with same file.

If production account is different, in the new production FCM account you have to configure the iOS app in the FCM API console for accessing the GCV API, download the plist file and replace it with the old one in same path. It should work perfectly.

Make sure to backup your old plist file before replacing with new one.

Upvotes: 1

Related Questions