It's NOT possible to use User-Defined settings in custom .plist file.
BUT you can copy your custom .plist file to the right place when building the app:
Create a new folder (for example: Resources/GoogleServiceInfoPlists
).
Copy there all .plist files for build configuration. For example:
GoogleService-Info-Debug.plist
GoogleService-Info-Stage.plist
GoogleService-Info-Prod.plist
Add new Run Script Phase
- Xcode: Target-->Build Phases-->"+" button (top left corner).
Use the script below to copy (replace) .plist file for given build configuration to the project directory:
cp "${SRCROOT}/${PRODUCT_NAME}/Resources/GoogleServiceInfoPlists/GoogleService-Info-$CONFIGURATION.plist" "${SRCROOT}/${PRODUCT_NAME}/GoogleService-Info.plist"
Under Output Files, you should possibly also enter the target file in order to ensure the next phase begins only if the file was actually copied.
"${SRCROOT}/${PRODUCT_NAME}/GoogleService-Info.plist"
Important: move newly added script before Copy Bundle Resources
phase, or it will use the default file, ignoring replaced file.
Used variables/paths:
${SRCROOT}
- predefined, it points to your project location.
${PRODUCT_NAME}
- predefined, product name.
$CONFIGURATION
- predefined, it's your build configuration. By default, it is: Debug
, Release
. In my case: Debug
, Stage
, Prod
. You can change build configurations in Xcode: Project (not Target!)-->Info.
Note:
GoogleService-Info.plist
file must be added to the Xcode project resources (Build Phases-->Copy Bundle Resources) while Resources/GoogleServiceInfoPlists/GoogleService-Info-*
files not necessarily.
If the above doesn't work try clicking in your disired .plist file > File Inspector > Target Membership > Check your main project so it can be bundled together in final output.