Xcodebuild'工作区并设置自定义构建路径

dre*_*kka 35 workspace xcodebuild

我正试图xcodebuild在工作区中构建一个多项目项目.当XCode构建工作空间时,它会自动将所有构建工件放在DerivedData的公共目录中,以便每个项目都可以访问它的依赖项.

如果我使用此命令:

xcodebuild -workspace myWorkspace.xcworkspace -schema builtIt -configuration Release
Run Code Online (Sandbox Code Playgroud)

Eveything可以工作,但工件放在通常的派生数据目录中.我希望然后出现在我可以从CI构建中访问的特定目录中.所以我尝试了这个

xcodebuild -workspace myWorkspace.xcworkspace -schema builtIt -configuration Release SYMROOT=build/products OBJROOT=build/intermediates
Run Code Online (Sandbox Code Playgroud)

然而xcodebuild失败了这个说法

Details:  Failed to load dependencies output contents from ``/Users/d4rkf1br3/projects/dNodi/build/intermediates/dNodi.build/Debug-iphoneos/dNodi.build/StaticAnalyzer/normal/armv7/DNRootSelector.d''. 
Error: Error Domain=NSCocoaErrorDomain Code=260 "The file “DNRootSelector.d” couldn’t be opened because there is no such file." 
UserInfo=0x4012fea40 {NSFilePath=/Users/d4rkf1br3/projects/dNodi/build/intermediates/dNodi.build/Debug-iphoneos/dNodi.build/StaticAnalyzer/normal/armv7/DNRootSelector.d, NSUnderlyingError=0x4012fc240 "The operation couldn’t be completed. No such file or directory"}. 
User info: {
    NSFilePath = "/Users/d4rkf1br3/projects/dNodi/build/intermediates/dNodi.build/Debug-iphoneos/dNodi.build/StaticAnalyzer/normal/armv7/DNRootSelector.d";
    NSUnderlyingError = "Error Domain=NSPOSIXErrorDomain Code=2 \"The operation couldn\U2019t be completed. No such file or directory\"";
}
Run Code Online (Sandbox Code Playgroud)

问题似乎是xcodebuild不再使用工作空间中所有项目的中央目录,而是将工件存储在每个项目中.因此,它无法找到正在编译的代码与其他项目中生成的工件之间的依赖关系.

有谁知道在命令行上设置正确的参数?

Xcode的Build Setting Reference已经有两年没有更新了,所以我不知道是否有新的构建设置我可以应用.

Nic*_*ina 41

我不确定这是否是一个新选项,但5.0版本xcodebuild有一个选项-derivedDataPath,允许您指定您希望所有构建产品所在的目录.

例如,传递-derivedDataPath build创建build相对于您运行的位置的文件夹xcodebuild,您可以在子文件夹中预测找到您的应用程序build/Build/Products/Release-iphoneos.

文档:https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/xcodebuild.1.html


Chi*_*man 19

到目前为止我找到的最好的解决方案是使用CONFIGURATION_BUILD_DIR带有ABSOLUTE路径的参数(例如/ tmp/$ PROJECT/build).像这样:

xcodebuild -scheme "scheme" -configuration Debug -sdk iphoneos clean build CONFIGURATION_BUILD_DIR=$ABSOLUTE_BUILD_PATH
Run Code Online (Sandbox Code Playgroud)

我使用Jenkins,我有一个名为变量的变量$WORKSPACE.随着$WORKSPACE/buildCONFIGURATION_BUILD_DIR的解决方案,我很高兴.

相对路径似乎没有按预期工作.我们应该提交错误报告.


SFe*_*eng 9

当我从Jenkins CI工具构建项目时,我也遇到了这个问题.我的主要项目取决于子项目.我试过建立跟随@ Chilloutman的解决方案,如下所示:

xcodebuild -target TravelGuideMdd -sdk iphoneos -configuration DailyBuild clean build CONFIGURATION_BUILD_DIR=/Users/mobileserver/jenkins_home/jobs/TravelGuide-Buid-For-Me/workspace/build BUILD_DIR =/Users/mobileserver/jenkins_home/jobs/TravelGuide-Buid-For-Me/workspace/build
Run Code Online (Sandbox Code Playgroud)

要么

xcodebuild -target TravelGuideMdd -sdk iphoneos -configuration DailyBuild clean build CONFIGURATION_BUILD_DIR=/Users/mobileserver/jenkins_home/jobs/TravelGuide-Buid-For-Me/workspace/build 
Run Code Online (Sandbox Code Playgroud)

它们都会出错 Could not find iphoneos in /Users/mobileserver/jenkins_home/jobs/TravelGuide-Buid-For-Me/workspace/build

但我最终成功地使用了这个:

xcodebuild -target TravelGuideMdd -sdk iphoneos6.1 -configuration DailyBuild clean build SYMROOT=/Users/mobileserver/jenkins_home/jobs/TravelGuide-Buid-For-Me/workspace/build 
Run Code Online (Sandbox Code Playgroud)

即:使用绝对路径设置SYMROOT.