6

I can't seem to find the answer.

I've just used Xcode 4 final version and built an existing project that was built ok with Xcode 3, but got this error:

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

But another project was built OK with Xcode 4.

I installed Xcode 4 by choosing the default options.

Do I miss to include a library or framework somewhere?

Could somebody please help. Thank you.

4 Answers 4

14

Here's my solution for Xcode 4.0.2 with SDK 4.3 environment, but I believe it should also work on other setups.

  1. libSystem.B.dylib is not present under /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk/usr/lib, however it is present for lower SDK versions (e.g. iPhoneOS4.2.sdk)
  2. most of the cases libSystem.B.dylib is just a symbolic link to libSystem.dylib
  3. so in iPhoneSimulator4.3.sdk/usr/lib I've applied following command sudo ln -s libSystem.dylib libSystem.B.dylib and my simulator builds started to work again :)

NOTE: libSystem.B.dylib is used by Flurry and Urban Airship so you better don't delete the reference in project file (of course Urban Airship does not work under Simulator, but I think Flurry does. libSystem.B.dylib may also be required by other libraries you included to your project.

UPDATE: solution still works for iOS5 Simulator after upgrading to Xcode 4.3

UPDATE, March 9th, 2k12: for Xcode installations via App Store, prefix above path with /Applications/Xcode.app/Contents or the path where you've installed Xcode.app.

Sign up to request clarification or add additional context in comments.

4 Comments

thank you for notifying this. Making the symbolic link works on me too. It could be a bug with the XCode version..
@Tanto: no problem, I just like SO community :) I think my solution is just a workaround that works rather than the real fix, which should be provided by Apple in next Xcode releases.
Still not fixed in iPhoneSimulator 5.0, but this fix worked for me.
The -weakl option (in XCode 4, this is an "Optional" link step) is needed to work on older devices, but breaks the sim. The above fix works for me, but is a glaring bug in XCode.
1

Solved.

Turns out that there was a reference to libSystemB in my project (Don't know why it's there). After deleting the reference, it built well.

Thanks anyway guys!

Comments

1

-weak_library /usr/lib/libSystem.B.dylib breaks the iOS Simulator. Use -weak-lSystem instead.

The quote belongs to gparker on the official dev forums.

Comments

0

I have the same problem since months and always kept making the symbolic link as described here everytime i updated xCode. Today I found a nice new way to fix this:

In your targets Build Phases go to 'Link Binary With Libraries' and search for: libz.dylib

Set from 'Required' to 'Optional'

BUILD

BE HAPPY

1 Comment

can u also give me the solution for solving on device. because its working on simulator but not on device

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.