冷雨之家

Dying is the day worth living for

Xcodebuild 使用注意事项

| Comments

1.xcodebuild cocoapod CONFIGURATION_BUILD_DIR

现象

xcodebuild命令用法示例
1
xcodebuild -sdk iphoneos -configuration ${BUILD_CONFIGURATION} -derivedDataPath="../build" -workspace '../SohuInk.xcworkspace' -scheme 'SohuInk_Jenkins' -archivePath "../SohuInk_Jenkins.xcarchive" archive

如果项目中使用了cocoapod并且xcodebuild 命令参数中指定了CONFIGURATION_BUILD_DIR并且值为相对路径,此时在Xcode Tools Version 5.0下的xcodebuild构建会报如下错误:

error_info
1
2
3
4
5
6
7
8
9
10
ld: warning: directory not found for option '-L/XXXX/XXXX/pop'
ld: library not found for -lAFNetworking
clang: error: linker command failed with exit code 1 (use -v to see invocation)

** ARCHIVE FAILED **

The following build commands failed:
  Ld /Users/XXXX/XXXX/Objects-normal/arm64/SohuInk normal arm64
  Ld /Users/XXXX/XXXX normal armv7
(2 failures)

解决方案

方案1,不好用

Xcode Tools version 5.0 支持参数 derivedDataPath 可以放弃CONFIGURATION_BUILD_DIR配置指定该参数,我实际操作是发现使用相对路径的情况下,虽然可以archive success,但是build的目录没有改变,依然在xcode默认的derivedData目录下.

方案2,OK

CONFIGURATION_BUILD_DIR的值指定为绝对路径,一切OK,可成功archive.

结论

xcodebuild中的CONFIGURATION_BUILD_DIR值需要使用绝对路径

参考链接

Stackoverflow上关于使用xcodebuild CONFIGURATION_BUILD_DIR最好使用绝对路径的说明 @Chilloutman
https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/xcodebuild.1.html

Comments