33

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?

Softlion
  • 11,311
  • 10
  • 52
  • 78
pqnet
  • 4,819
  • 1
  • 23
  • 44

2 Answers2

60

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.

swalkner
  • 15,150
  • 25
  • 107
  • 195
Laurent Etiemble
  • 25,779
  • 5
  • 52
  • 81
  • 3
    according to the reference provided looks like using ONLY_ACTIVE_ARCH=YES and CURRENT_ARCH=i386 should work for what i want to do but CURRENT_ARCH (or NATIVE_ARCH which has same meaning) but apparently those two variables can't be overridden (and nothing seems to suggest it from documentation). Proposed approach did work (and actually it makes sense once you understand active arch is the build system's architecture instead of the one you selected in Xcode) but probably a better choice of word for that definition would have helped. Thanks! – pqnet May 30 '11 at 09:29
  • 4
    You can use `xcodebuild VALID_ARCHS=i386 CURRENT_ARCH=i386 ONLY_ACTIVE_ARCH=YES ....` – David Hernandez Feb 26 '13 at 15:17
  • 2
    Just adding ONLY_ACTIVE_ARCH=NO did it for me – Fabio Russo Aug 23 '13 at 07:32
  • 2
    For 64 bit simulator / os: ARCHS='x86_64' VALID_ARCHS='x86_64' – eladleb Sep 01 '14 at 17:32
  • What does Geoptima to do with this here? The `ONLY_ACTIVE_ARCH=NO` answer is correct, your comment is useless – Adaptabi Apr 15 '15 at 12:28
1

xcodebuild ONLY_ACTIVE_ARCH

xcodebuild ONLY_ACTIVE_ARCH...
//or
Build Settings -> Build Active Architecture Only -> ONLY_ACTIVE_ARCH

YES - build binary with a single architecture for a connected device

NO - build binary for a specific -arch(valid architectures aka VALID_ARCHS) if it was specified or for all the architectures in other cases

The recommendation is to use Yes for Debug(it save a build time) and No for Release build.

enter image description here

Note: it is safety to run on simulator

To check the version use lipo -info[About]

yoAlex5
  • 13,571
  • 5
  • 105
  • 98