简体   繁体   English

Xcode:如何使xcodebuild构建一个包含子项目的项目

[英]Xcode: How to make xcodebuild build a project that contains sub-projects

I have an Xcode project that contains several sub-projects (framework projects that compile as lib files) as part of the main project. 我有一个Xcode项目,它包含几个子项目(编译为lib文件的框架项目)作为主项目的一部分。 The project compiles/builds properly in Xcode (builds the sub-projects correctly from the bottom of the hyarchial tree up to the main app project). 该项目在Xcode中正确编译/构建(从hyarchial树的底部到主app项目正确构建子项目)。

I am now trying to set up the project for Continuous Integration, and when I attempt to build from the command line using xcodebuild... the build fails due to not finding the .a files that should have been built before the main project. 我现在正在尝试为持续集成设置项目,当我尝试使用xcodebuild从命令行构建时...由于没有找到应该在主项目之前构建的.a文件,构建失败。

I can build each of the lib files from the cmd line independently, but the entire consolidated project fails. 我可以独立地从cmd行构建每个lib文件,但整个合并项目失败。 Even though I have the dependancies correctly managed in the target scheme and if I specify the target or scheme when I use xcodebuild, it still will not build the sub-projects. 即使我在目标方案中正确管理了依赖项,并且如果我在使用xcodebuild时指定目标或方案,它仍然不会构建子项目。

Is there a way to make xcodebuild build the sub-projects and then the main project as it does in the Xcode IDE? 有没有办法让xcodebuild构建子项目,然后像Xcode IDE一样构建主项目? If not, would this work if I converted the entire project into a workspace? 如果没有,如果我将整个项目转换为工作区,这会有效吗?

Any help or suggestions would be greatly appreciated. 任何帮助或建议将不胜感激。 I am running Xcode 5.1.1 on Mavericks. 我在Mavericks上运行Xcode 5.1.1。

The solution was a simple one... using the "-scheme" flag instead of "-target" allowed the project to build correctly (all sub-projects/frameworks and then target App) 解决方案很简单...使用“-scheme”标志而不是“-target”允许项目正确构建(所有子项目/框架然后目标应用程序)

FAILED: 失败:

xcodebuild -project MyProject.xcodeproj -target MyProject -sdk "iphoneos" -configuration “Build” archive OBJROOT=../../build_iOS/Obj.root SYMROOT=../../build_iOS/Sym.root 

BUILT AS EXPECTED: 如预期的那样:

xcodebuild -project MyProject.xcodeproj -scheme MyProject -sdk "iphoneos" -configuration “Build” archive OBJROOT=../../build_iOS/Obj.root SYMROOT=../../build_iOS/Sym.root 

There was no need to convert the project to a workspace. 无需将项目转换为工作区。

You need to use a workspace to build multiple projects. 您需要使用工作区来构建多个项目。 Also, since you are moving to a CI server, be sure to share your schemes. 此外,由于您要迁移到CI服务器,请务必共享您的方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM