Search code examples
iphoneiosjailbreakarc4random

Lazy symbol binding failed: Symbol not found: _arc4random_uniform


So I programming an iOS game and I'm using arc4random_uniform for choosing a random powerup.

On the Sim, it works fine, but on my phone it throws this error (from the syslog):

Nov 26 13:44:26 iPhone ----[2184]: placePowerupCalled
Nov 26 13:44:26 iPhone UIKitApplication:com.yourcompany.-----[0x1f08][2184]: dyld:  lazy symbol binding failed: Symbol not found: _arc4random_uniform
Nov 26 13:44:26 iPhone UIKitApplication:com.yourcompany.-----[0x1f08][2184]:   Referenced from: /Applications/------.app/-----
Nov 26 13:44:26 iPhone UIKitApplication:com.yourcompany.------[0x1f08][2184]:         Expected in: /usr/lib/libSystem.B.dylib
Nov 26 13:44:26 iPhone UIKitApplication:com.yourcompany.------[0x1f08][2184]: dyld: Symbol not found: _arc4random_uniform
Nov 26 13:44:26 iPhone UIKitApplication:com.yourcompany.-----[0x1f08][2184]:   Referenced from: /Applications/------.app/-------
Nov 26 13:44:26 iPhone UIKitApplication:com.yourcompany.-----[0x1f08][2184]:   Expected in: /usr/lib/libSystem.B.dylib
Nov 26 13:44:27 iPhone ReportCrash[2185]: Formulating crash report for process -----[2184]
 Nov 26 13:44:27 iPhone com.apple.launchd[1] (UIKitApplication:com.yourcompany.-----[0x1f08][2184]): (UIKitApplication:com.yourcompany.-----[0x1f08]) Job appears to have crashed: Trace/BPT trap
Nov 26 13:44:27 iPhone SpringBoard[2161]: Application '-----' exited abnormally with signal 5: Trace/BPT trap

I'm not quite sure what the problem is. I've even included the header file arc4random should come from (#include "stdlib.h"), but that hasn't worked.

Anyone have any ideas? Thanks !:)


EDIT: I tried linking binary with the "libSystem.b.dylib" library, but that didn't work either and it's still crashing from the same error.


Solution

  • arc4_uniform function was added in iOS 4.3 and won't run on lower versions. Looks like you run simulator on 4.3 or higher but your device has lower iOS version. If you plan to support your app on versions lower than 4.3, try using this instead:

    arc4random() % upperBoundExclusive
    

    It might be not as precisely random as arc4_uniform, but will work.