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

how-to-check-xcode-predefined-variables

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:

how-to-check-xcode-predefined-variables

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:

how-to-check-xcode-predefined-variables

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.

how-to-check-xcode-predefined-variables
所有订阅均支持 12 期免息分期

¥ 59

按月订阅

一个月,观看并下载所有视频内容。初来泊学,这可能是个最好的开始。

开始订阅

¥ 512

按年订阅

一年的时间,让我们一起疯狂地狩猎知识吧。比按月订阅优惠 28%

开始订阅

¥ 1280

泊学终身会员

永久观看和下载所有泊学网站视频,并赠送 100 元商店优惠券。

我要加入
如需帮助,欢迎通过以下方式联系我们