4

I have been given the task of adding a few features to an iOS app. I checked out the source on SVN to be greeted with over 100 warnings (argh), thankfully I'm down to the last one, which is:

Xcode warning

(The blocked out bits are the client name...).

I believe this warning is saying something along the lines of: 'this XML library is not compatible with the OS architecture that is being linked on the build'.

With the next release, we are supporting only iOS5 and iPhone 4 and above (rather than lower versions of iOS and older iPhones).

So do I change the link architecture? What is the link architecture? How do I change the architecture? Or am I completely on the wrong track?

May be worth mentioning that I am running the latest Xcode, I've added the framework from the Xcode list (link binary with libraries).

EDIT

I only get the message when building from the simulator. It doesn't cause any harm, just winds me up!

Thanks in advance.

Adam Waite
  • 19,175
  • 22
  • 126
  • 148
  • add libxml2.2.dylib in you project or http://stackoverflow.com/questions/5220435/file-was-built-for-i386-which-is-not-the-architecture-being-linked-x86-64-whil – iPatel Mar 25 '13 at 15:29

4 Answers4

3

Do not link against libxml2.2.dylib, instead link against libxml2.dylib. Linking against that should ensure you are always linked against the correct implementation for your architecture.

As a general rule, in your applications link to the generic version of a library rather than a specific version. In this case this means libxml2 rather than libxml2.2 .

You are linking to a (symlink to a) dynamic library which at runtime will automatically point to the correct implementation for the current OS version and architecture. Linking to the specific version of a library does not guarantee this, and you can end up linking to a something that only has a single architecture. Thus, during development if you link to libxml2.2.dylib when targetting the simulator you may be linking against something that is i386, then when you target a device it can't find the correct architecture (because it's trying to use i386 for armvWhatever, which is exactly what you are telling it do).

quellish
  • 21,123
  • 4
  • 76
  • 83
  • Is there a difference between the libraries? I didn't write this code in the first place and have never used the lib. – Adam Waite Mar 27 '13 at 10:59
  • This works, but I don't think it is explained enough to merit the bounty. If you expand on your answer saying for what reason it was failing, and why 2 works but not 2.2 I'll award it. Thanks! – Adam Waite Mar 27 '13 at 11:05
  • I'm linking to the libxml2.dylib generic version but I still get the crash in Leopard: "Incompatible library version: requires version 10.0.0 or later, but libxml2.2.dylib provides version 9.0.0 leopard" – aneuryzm Mar 12 '14 at 09:35
  • It's telling you that your (leopard) version is too old. – quellish Mar 16 '14 at 02:05
1

If you're trying to use libxml2.2, it's already available in Xcode. Instead of getting it from an outside source (Apple wouldn't let you use a dynamic library anyway), add it in Xcode to your frameworks, and then link it by adding /usr/lib/libxml2/ in Header Search Paths. Don't link your project with a dylib that's not Apple provided or else your app will get rejected. Also, the architecture i386 isn't the architecture for iOS, as iOS uses the armv7 and armv7s architectures for the newer versions of their devices, which is why you are getting the architecture warning.

Chris Loonam
  • 5,735
  • 6
  • 41
  • 63
  • I've added the framework from the Xcode list (link binary with libraries). I only get the message when building from the simulator. It doesn't cause any harm, just winds me up! – Adam Waite Mar 27 '13 at 09:37
0

Basically the difference between libxml2.2 and libxml2 is that libxml2.2 points to a specific version/implementation of libxml whereas libxml2 is a shortcut/symlink that points to the latest version AND correct architecture of libxml2 that XCode can find. Therefore when adding a framework like this, you should always add the 'general version' (the symlink) of it (libxml2) rather than the 'specific version' of it (libxml2.2) because of the exact issue you're seeing.

Hope this helps!

Jai Govindani
  • 3,181
  • 21
  • 26
-1

That says you're linking to something built for 386 not arm. You will either need a different dylib to link to or go into project settings and change the arch. ( if you are building the dylib) Probably to include arm7 or similar.

uchuugaka
  • 12,679
  • 6
  • 37
  • 55