Search code examples
ioslinkerxcode4

How can I build in XCode 4, for an iOS 3.1 deployment target, using libSystem.B?


I've recently upgraded from XCode 3 to 4, and now I'm having build problems with my iPhone project. I need to support older versions of iOS back to 3.1. With XCode 3.2.5, I had no problem building with SDK 4.2, using an iOS deployment target of 3.1. I also included a weak link to the libSystem.B library, which is required for running the app on older iOS versions. Now when I build with XCode 4, I get the linker error below. The compilation step completes, but the link step fails. If I remove the weak link to the libSystem.B library, then the build completes, but the app crashes at startup when running on iOS 3.1.

Has anyone found a solution to this problem? How do you build with XCode 4, to run on an old version of iOS?

ld: library not found for -lSystem.B collect2: ld returned 1 exit status Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc-4.2 failed with exit code 1


Solution

  • In your project build settings under "Other Linker Flags" add the following:

    -weak_library /usr/lib/libSystem.B.dylib

    It should automatically be added to your Target build settings but if it isn't you should add it there as well.