views:

1126

answers:

3

I recently added a static library (mobclix) to my iPhone project which required me to set the Base SDK to 3.0. This library is claimed to be compatible with 2.2 and so far it looks like it's true. I set the project's Deployment Target to 2.2. No problems there.

Now, I am also using libxml2 in this same project. Apparently, the libxml2.2.dylib in OS 3.0 is newer than in OS 2.X (version 10 and 9 respectively). However, my code that uses libxml2, was already compatible with the libxml2 version included with OS 2.X. Since I needed to set the Base SDK to 3.0, the "compatibility version" / minimum version requirement / dependency is automatically set to the newer version of libxml2. When I try to run the app in OS 2, I get this runtime error (obviously):

  Dyld Error Message:
  Library not loaded: /usr/lib/libxml2.2.dylib
  Referenced from: /Users/Martijn/Library/Application Support/iPhone Simulator/User/Applications/4D5456DE-F297-4DF4-ACA6-DA8BBBBBA914/Luisterpaal.app/Luisterpaal
  Reason: Incompatible library version: Luisterpaal requires version 10.0.0 or later, but libxml2.2.dylib provides version 9.0.0

Is it possible to override the version requirement somewhere? Or other ideas to solve this issue?

A: 

The compatibility version is set according to the version embedded in the dylib of the current SDK during build. I have not found a way to change or override this.

However, in the target in Xcode under the "Link with binary with libraries" branch there is an option to link a dylib "weakly". This skips version checking at the time of loading the dylib (runtime). It's your responsibility then to only make calls to existing functions. Making calls to non-existent functions will crash the application.

Martijn Thé
A: 

I've found a truly awful way to work around this. Copy the library from version 2.2 of the SDK over the top of version 3.0 and it'll get picked up instead at link-time. You'll need to use the sudo command to get the copy to work and I found sudo only works if the logged in user has a non-blank password.

Does anyone have a better way?

Jon B
A: 

Apparently there was a change with SDK 3.0 that broke compatibility with libxml. Apple have posted about it here:

http://developer.apple.com/iphone/library/qa/qa2009/qa1659.html

mtully