Installation procedure for pre-build actions to automatically populate Xcode Info.plist with dynamic data.
Edit Xcode Scheme and add a pre-action script.
Copy the contents of preaction.sh
into the pre-action script box.
- Copy
build_environment.sh
toconfig/environments/build_environment.sh
. - Modify it's variables or path to
environment_preprocess.h
as needed.
- For the
Project Build Settings
add a new User-Defined variables calledENVIRONMENT
, for each scheme set the appropriate name egdevelopment
orproduction
. - For each Target Build Settings set
Preprocess Info.plist file
to YES. - Enter
environment_preprocess.h
(or the output file if you renamed itbuild_environment.sh
) intoInfo.plist Preprocessor Prefix File
Copy development.plist
file to config/environments/development.plist
. DO NOT include this file in any Target Memberships.
If you have several schemes setup in the previous step (ENVIORMENT
) you need to copy this file to each option if you use multiple build schemes and ENVIRONMENT
variables.
This file development.plist
(and others) is used to populate data in the build_environment.sh
script.
Modify contents as needed and don't forget to also modify the build_environment.sh
accordingly.
This is really where the magic happens. The rest is just for running this script and processing the output.
TIP 1: You can run pretty much anything in the environment_preprocess.h
script if you want to setup link to a local development server you can use the hostname
command to get your current build computer's network name.
TIP 2: You can use it to use git commit count as the build version/number.
(Both of these are included in the script already.)
- Use those generated environment variables in your
Info.plist
.
This will generate the environment_preprocess.h
file and make it available for inclusion in your Info.plist
It's advisable to exclude the generated file from any version control system.