macosdebuggingcommand-linexcode4xcodebuild

How can I build a specific architecture using xcodebuild?


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?


Solution

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