首页 > ios > xcode4的环境变量详解

xcode4的环境变量详解

$(BUILT_PRODUCTS_DIR)
build成功后的,最终产品路径--可以在Build Settings参数的Per-configuration Build Products Path项里设置

$(TARGET_NAME)
目标工程名称

$(SRCROOT)
工程文件(比如Nuno.xcodeproj)的路径

$(CURRENT_PROJECT_VERSION)
当前工程版本号

其他:

当编译静态库,设备选模拟器(iPhone 5.0 Simulator),未设置任何Build Settings参数时,默认的基础路径:

/Users/xxx/Library/Developer/Xcode/DerivedData/xxxWorkspace-caepeadwrerdcrftijaolkkagbjf

下面用$()代替上面一长串东东

$(SYMROOT) = $()/Build/Products

$(BUILD_DIR) = $()/Build/Products

$(BUILD_ROOT) = $()/Build/Products

这三个变量中的$()不会随着Build Settings参数的设置而改变

相反,以下可以通过设置而改变

$(CONFIGURATION_BUILD_DIR) = $()/Build/Products/Debug-iphonesimulator

$(BUILT_PRODUCTS_DIR) = $()/Build/Products/Debug-iphonesimulator

$(CONFIGURATION_TEMP_DIR) = $()/Build/Intermediates/UtilLib.build/Debug-iphonesimulator

$(TARGET_BUILD_DIR) = $()/Build/Products/Debug-iphonesimulator

$(SDK_NAME) = iphonesimulator5.0

$(PLATFORM_NAME) = iphonesimulator

$(CONFIGURATION) = Debug

$(TARGET_NAME) = UtilLib

$(EXECUTABLE_NAME) = libUtilLib.a 可执行文件名

${IPHONEOS_DEPLOYMENT_TARGET} 5.0

$(ACTION) = build

$(CURRENTCONFIG_SIMULATOR_DIR) 当前模拟器路径

$(CURRENTCONFIG_DEVICE_DIR) 当前设备路径

$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME =

$()/Build/Products/Debug-iphonesimulator

$(PROJECT_TEMP_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) = $()/Build/Intermediates/UtilLib.build/Debug-iphonesimulator

自定义变量

${CONFIGURATION}-iphoneos 表示:Debug-iphoneos

${CONFIGURATION}-iphonesimulator 表示:Debug-iphonesimulator

$(CURRENTCONFIG_DEVICE_DIR) = ${SYMROOT}/${CONFIGURATION}-iphoneos

$(CURRENTCONFIG_SIMULATOR_DIR) = ${SYMROOT}/${CONFIGURATION}-iphonesimulator

自定义一个设备无关的路径(用来存放各种架构arm6/arm7/i386输出的产品)

$(CREATING_UNIVERSAL_DIR) = ${SYMROOT}/${CONFIGURATION}-universal

自定义变量代表的值

$(CURRENTCONFIG_DEVICE_DIR) = $()/Build/Products/Debug-iphoneos

$(CURRENTCONFIG_SIMULATOR_DIR) = $()/Build/Products/Debug-iphonesimulator

$(CREATING_UNIVERSAL_DIR) = $()/Build/Products/Debug-universal

iphoneos5.0下的编译脚本:

xcodebuild -project “UtilLib.xcodeproj” -configuration “Debug” -target “UtilLib” -sdk “iphoneos5.0” -arch “armv6 armv7″ build RUN_CLANG_STATIC_ANALYZER=NO $(BUILD_DIR)=”${BUILD_DIR}” BUILD_ROOT=”${BUILD_ROOT}”

iphonesimulator5.0下的编译脚本:

xcodebuild -project “UtilLib.xcodeproj” -configuration “Debug” -target “UtilLib” -sdk “iphonesimulator5.0” -arch “i386″ build RUN_CLANG_STATIC_ANALYZER=NO $(BUILD_DIR)=”${BUILD_DIR}” BUILD_ROOT=”${BUILD_ROOT}”

加上下面一句表示输出到文件:

> “${BUILD_ROOT}.build_output”

lipo脚本工具:合并iPhone模拟器和真机的静态类库,生成通用库

lipo -create -output “${CREATING_UNIVERSAL_DIR}/${EXECUTABLE_NAME}” “${CURRENTCONFIG_DEVICE_DIR}/${EXECUTABLE_NAME}” “${CURRENTCONFIG_SIMULATOR_DIR}/${EXECUTABLE_NAME}”

意思是:把”${CURRENTCONFIG_DEVICE_DIR}目录下的.a文件,和${CURRENTCONFIG_SIMULATOR_DIR}目录下的.a文件合并,

在${CREATING_UNIVERSAL_DIR}目录下,生成两个设备都通用的静态库,

例如:lipo -create -output xy.a x.a y.a

还有一个编译的自动打包脚本,github上面公开的
连接:https://gist.github.com/adamgit/3705459

  1. 还没有评论
评论提交中, 请稍候...

留言


可以使用的标签: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>
Trackbacks & Pingbacks ( 0 )
  1. 还没有 trackbacks