For a long time, I had been having some questions like:
- Is there a full list of Xcode predefined environment variables?
- What are theirs values and How to check them?
For example, when integrating frameworks by carthage, we may add input files like this:
$(SRCROOT)/Carthage/Build/iOS/Kingfisher.framework
and output files like this:
$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/Kingfisher.framework
How can we know Xcode has predefine environment variables like $(SRCROOT) / $(BUILT_PRODUCTS_DIR) / $(FRAMEWORKS_FOLDER_PATH)
? What are their values when building my project?
Although I have been working on iOS development for many year, I'm not quite clear about them. If you have the same problems, here is the answer :)
Build settings reference
Open Xcode, click Help -> Xcode Help, search build settings reference
Here is a full list of Xcode predefined variables and their explanation.
Get environment variable values at build time
In order to get a full list of Xcode environment values at build time, we can add a Run Script at Build Phases and enable Show environment variables in build log:
Add the following shell snippet:
/bin/zsh
export
Now, build your project, switch to Log Navigator and check the latest building blog. You'll find a list of environment variable values in the Run custom shell script section:
Another Xcode tips
If you want to know a speicific Xcode build setting, press option
and double click it. Xcode will popup an explanation panel.