Xcode环境变量
2016-06-23 本文已影响1237人
Crazy2015
约定1:
~=当前账户的HOME目录,例如“/Users/crazy”
约定2:
build构建基础路径:
BUILD_PATH = ~/Library/Developer/Xcode/DerivedData/Build。
可通过“File->Project Settings”查看Derived Data Location。
或者
Xcode ->Preferences->Locations->Derived Data 来设置
以下背景结构:
XCSDKDemoWorkspace目录:此目录下面有.xcworkspace文件,
同时还有XCSDKDemo目录:此目录下面有.xcodeproj文件
和XCSDK目录
现在以XCSDKDemo目录下面的XCSDKDemo.xcodeproj来讨论
build构建基础路径:
/Users/crazy/Desktop/XCSDKDemoWorkspace/XCSDKDemo/DerivedData/Build/
SYMROOT = /Users/crazy/Desktop/XCSDKDemoWorkspace/XCSDKDemo/DerivedData/Build/Products
#####XCSDKDemo.xcodeproj所在的目录
SRCROOT = /Users/crazy/Desktop/XCSDKDemoWorkspace/XCSDKDemo
CONFIGURATION_BUILD_DIR = /Users/crazy/Desktop/XCSDKDemoWorkspace/XCSDKDemo/DerivedData/Build/Products/Debug-iphoneos
BUILD_DIR = /Users/crazy/Desktop/XCSDKDemoWorkspace/XCSDKDemo/DerivedData/Build/Products
BUILD_ROOT = /Users/crazy/Desktop/XCSDKDemoWorkspace/XCSDKDemo/DerivedData/Build/Products
约定3:环境变量宏(Build Setting Macros)引用格式:${MACRO},同Build Phases Run Script中的语法。
(b) PROJECT & SOURCE
PROJECT = XMPayAndRedeemSDKDemo
PROJECT_DIR = /Users/crazy/Desktop/XCSDKDemoWorkspace/XCSDKDemo
PROJECT_FILE_PATH =${PROJECT_DIR}/XCSDKDemo.xcodeproj
PROJECT_NAME = XCSDKDemo
SOURCE_ROOT =${PROJECT_DIR}
SRCROOT =${PROJECT_DIR}
(c) BUILD & CONFIGURATION
BUILD_PATH = /Users/crazy/Desktop/XCSDKDemoWorkspace/XCSDKDemo/DerivedData/Build/
BUILD_DIR = BUILD_PATH/Products
BUILD_ROOT = BUILD_PATH/Products
BUILT_PRODUCTS_DIR = BUILD_PATH/Products/Debug-iphoneos
CONFIGURATION = Debug
CONFIGURATION_BUILD_DIR =BUILD_PATH/Products/Debug
(d) PRODUCT & TARGET
PRODUCT_NAME = XCSDKDemo
PRODUCT_TYPE = com.apple.product-type.tool// Project Template: Command Line Tool
TARGET_BUILD_DIR =BUILD_PATH/Products/Debug
TARGET_NAME = XCSDKDemo
5)构建输出目录(Preferences->Locations->Locations)
当选择为Default时,Derived Data的目录为~/Library/Developer/Xcode/DerivedData。
当选择为Relative时,Derived Data的目录为当前.xcodeproj所在的目录。
当选择为Custom时,Derived Data的目录需自定义。
不建议使用绝对路径,因为写死之后,换环境或换平台,又要重新修改路径,建议使用相对路径(Relative)。
1)查看环境变量宏
命令行进入HelloWorld工程目录,执行xcodebuild命令并带上“-showBuildSettings”参数:
$ xcodebuild -project HelloWorld.xcodeproj -target HelloWorld -configuration Debug -showBuildSettings > xcodebuild_showBuildSettings.txt
则xcodebuild_showBuildSettings.txt中保存了Build settings for action build and target "HelloWorld”,其中dump了所有的环境变量。
参考: