Ios – Xcode: How to make xcodebuild build a project that contains sub-projects

iosxcodexcodebuild

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).

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.

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.

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?

Any help or suggestions would be greatly appreciated. I am running Xcode 5.1.1 on Mavericks.

Best Answer

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)

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.

Related Topic