I have some xcconfig files setting different values for Dev, Stage, & Prod environments.
It's working when used in conjunction with Info.plist, however I want to extend it to use it with GoogleService-Info.plist (as I am using different Firebase stores for different environments). But its not working with GoogleService-Info.plist, for example in an xcconfig file I have defined:
FIREBASE_API_KEY = AIzaSyCR2X-bvYU0Zuf_uaoQXzGZqYSUbNbvCZ4
Then in GoogleService-Info.plist I have:
<dict>
<key>API_KEY</key>
<string>$(FIREBASE_API_KEY)</string>
However when the app is run, there is an exception in Firebase as the value for API_KEY has not been set to that in the .xcconfig.
Why does the substitution work for Info.plist files but not for GoogleService-Info.plist files?
Info.plist is processed specifically by xcode to perform variable substitution. See:
This is only for Info.plist. It doesn't apply to other plist files.
Google's plist is processed separately by their own SDK (at the time the Firebase SDK is initialized) and doesn't perform variable substitution. See the API documentation for FirebaseApp.configure():
This method should be called from the main thread and contains synchronous file I/O (reading GoogleService-Info.plist from disk).
If you want variable substitution for that file, you'll likely have to process that plist yourself in a similar way that xcode does it, build a FirebaseOptions object, then feed that to the Firebase SDK directly using FirebaseApp.configure(options) instead of allowing it to process the file as it does normally.