How can I build a specific architecture using xcodebuild?

pqnet picture pqnet · May 27, 2011 · Viewed 34.4k times · Source

I have legacy code that relies on pointers being 32-bit and want to use xCodeBuild to build that code from command line. This doesn't work for some reason. Here's the command I use:

xcodebuild -configuration Debug -arch i386 
  -workspace MyProject.xcworkspace -scheme MyLib

here's the output I get

[BEROR]No architectures to compile for 
  (ONLY_ACTIVE_ARCH=YES, active arch=x86_64, VALID_ARCHS=i386).

Clearly it's trying to build x86_64 code and failing miserably since I only enabled i386 from VALID_ARCHS in xCode project settings.

Is there a way to make it understand I don't want a 64-bit library?

Answer

Laurent Etiemble picture Laurent Etiemble · May 27, 2011

You have to set the ONLY_ACTIVE_ARCH to NO if you want xcodebuild to use the ARCHS parameters. By passing these parameters, you can force the proper architecture.

xcodebuild ARCHS=i386 ONLY_ACTIVE_ARCH=NO -configuration Debug -workspace MyProject.xcworkspace -scheme MyLib

See this reference for details.