Irina Rapoport
Irina Rapoport

Reputation: 1692

How to remove unwanted architecture x86_64 from Xcode build?

I am trying to recompile someone else's code. The code includes a reference to a third party library myLib.a, which has two slices:

Architectures in the fat file: myLib.a are: armv7 arm64 

I get this warning, following by a bunch of link errors:

ld: warning: ignoring file myLib.a, missing required architecture x86_64 in file myLib.a (2 slices)

Now, I know this library is not intended to work in a simulator. So I want to throw the simulator away from build. I don't really understand build targets, so I did this:

enter image description here

Still, same error. What am I doing wrong?

Xcode 7.3

Upvotes: 1

Views: 8009

Answers (2)

JhonnyTawk
JhonnyTawk

Reputation: 863

I answered this question here: https://stackoverflow.com/a/65307436/5303139

Same anwser

For an iOS project, you have the following architectures: arm64 armv7 armv7s i386 x86_64

x86_64, i386 are used for the simulator.

What could be your problem is the framework you are using was build for iOS and not a simulator.

To fix this issue you can bypass the build framework and use lipo command lines.

First: lipo -info [The library.framework location]

Example Usage : lipo -info /Users/.../library.framework/LibrarySDK

Example output :

Architectures in the fat file: /Users/.../library.framework/LibrarySDK are: i386 x86_64 armv7 arm64 

You will get the list of architecture used for that framework.

Second: we need to strip the framework from the simulator architecture and make 2 versions of that framework (1 is used for iOS Device and 1 for the simulator)

using: lipo -remove [architecture] [location] -o [output_location]

Example: lipo -remove i386 /Users/.../SDK -o /Users/.../SDK_Output_Directory

Go to your chosen output directory to get the new generated SDK without the removed architecture to verify you can use the lipo -info command same as above

You can use the same lipo remove command on the newly created SDK but with another architecture lipo -remove x86_64 ... and you will get an SDK only for iOS devices

Third: Take that final SDK and rename it "SDK_Name_IOS" and use it.

Happy coding!!

Upvotes: 3

larva
larva

Reputation: 5148

You did set architect to armv7, arm64 so just change Build Active Architecture Only to YES in debug mode:

debug mode: YES

release mode: NO (default value)

So when debug you will build only for current device

Upvotes: 2

Related Questions