Xcode:如何让 xcodebuild 构建包含子项目的项目
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23689464/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Xcode: How to make xcodebuild build a project that contains sub-projects
提问by SeaWolf
I have an Xcode project that contains several sub-projects (framework projects that compile as lib files) as part of the main project. 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 项目,其中包含几个子项目(编译为 lib 文件的框架项目)作为主项目的一部分。该项目在 Xcode 中正确编译/构建(从 hyarchial 树的底部到主应用程序项目正确构建子项目)。
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. 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.
我可以从 cmd 行独立构建每个 lib 文件,但整个合并项目失败。即使我在目标方案中正确管理了依赖项,并且如果我在使用 xcodebuild 时指定目标或方案,它仍然不会构建子项目。
Is there a way to make xcodebuild build the sub-projects and then the main project as it does in the Xcode IDE? If not, would this work if I converted the entire project into a workspace?
有没有办法让 xcodebuild 构建子项目,然后像在 Xcode IDE 中那样构建主项目?如果没有,如果我将整个项目转换为工作区,这会起作用吗?
Any help or suggestions would be greatly appreciated. I am running Xcode 5.1.1 on Mavericks.
任何帮助或建议将不胜感激。我在小牛队上运行 Xcode 5.1.1。
回答by SeaWolf
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.
无需将项目转换为工作区。
回答by sylvanaar
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 服务器,请务必共享您的方案。