Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 241
pqnet Avatar asked May 27 '11 11:05

pqnet


People also ask

What is build active architecture only?

The "build active architecture only" setting causes everything except the current Mac's architecture to be ignored (and the current one is of course valid), hiding the problem. Instead, you should look up a row or two in the settings, and change the "Architectures" setting to "Standard".

Where is valid architectures in Xcode?

If a project includes VALID_ARCHS, the setting is displayed in the User-Defined section of the Build Settings editor.

What is Xcodebuild command?

xcodebuild is a command-line tool that offers the ability to build and test your Xcode projects.


2 Answers

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.

like image 79
Laurent Etiemble Avatar answered Sep 21 '22 18:09

Laurent Etiemble


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]

like image 33
yoAlex5 Avatar answered Sep 22 '22 18:09

yoAlex5