9

I am trying to run unsigned application on iOS 5.1/iPhone 4s (jailbroken). What I did:

  1. Disable code signing in XCode.

  2. Built unsigned iPhone app.

  3. Copied it to my iPhone via SSH to location /User/me/development/HelloWorld.app

  4. Now I try to simulate its signing to run this application on iPhone. I run follwing commands:

.

cd /User/me/development
chmod -R 777 HelloWorld.app
ldid -S HelloWorld

However, I receive following error:

util/ldid.cpp(567): _assert(78:arch != NULL)

What are possible reason of such error and now to fix it?

Cyrille
  • 25,014
  • 12
  • 67
  • 90
Vitalii
  • 4,434
  • 4
  • 35
  • 77

3 Answers3

11

1) Using ldid -S is the correct usage. Not lowercase (-s).

2) Usually, when I get this error, it's because I built my app with the wrong architectures. Most older versions of ldid that I've used cannot sign fat binaries (but see Update below). Fat binaries are ones with more than one architecture inside. For example, a dual armv6 and armv7 executable. Or with Xcode 4.5, it's probably defaulting to armv7 and armv7s.

In the project build settings, use the Architectures, Valid Architectures and Build Active Architecture Only settings to determine which architecture executable is built. For jailbreak development, I usually set Build Active Architecture Only to YES. And valid archictures set to armv6 and armv7.

3) Also, some older versions of ldid cannot sign armv7 executables. If you get the pre-built copy from KennyTM's site here, it supports armv7. Note that this ldid is built for Mac OS X, so it's designed to be run on the executable on your Mac, after building without signing in Xcode, but before you upload to your iPhone.

Newer phones can generally run executables built for older architectures, but not the other way around. So, build for the oldest architecture you want to support. You just will lose some optimizations in the newer architectures (which most people don't care too much about ... let me know if your app needs these optimizations, and I'll post more).

So, if you want to support old devices (iPhone < 3GS), I would set Architectures to only armv6, making sure to remove the default setting of $(ARCHS_STANDARD_32_BIT). If you only need support for relatively new ones, then pick armv7, but make sure you use a version of ldid that can sign armv7 binaries.

Edit: to determine if the executable you were trying to sign was a fat one, run this at the command line:

> cd HelloJB.app

> ls
HelloJB     Info.plist  PkgInfo     date.zip    en.lproj

> lipo -info HelloJB 
Non-fat file: HelloJB is architecture: armv7

As you can see in the above output, my HelloJB executable is not fat, and only has armv7 code.

Update

I believe that the pre-built version of ldid found here can now sign fat executables, although there are still ldid versions floating around that cannot. Also, I think that if you install a recent version of iOSOpenDev, it will give you a version of ldid that can sign fat executables (default install location of /opt/iOSOpenDev/bin/ldid).

Community
  • 1
  • 1
Nate
  • 31,017
  • 13
  • 83
  • 207
  • Thanks, you right, I use mixed architecture armv7/7s, it must be the reason. – Vitalii Oct 10 '12 at 12:03
  • 1
    @VASoftOnline, yep. That's now the default for XCode. I would just set the architecture to **only** build for `armv7`, and then let `ldid` code sign that non-fat executable. – Nate Oct 10 '12 at 21:24
  • My iPod must hate me. I have just this problem and tried this solution to no avail. Even lipo fails: 'dyld: lazy symbol binding failed' – spamguy Oct 19 '12 at 03:07
  • 1
    @spamguy, [there are other ways to check for a fat binary, too](http://stackoverflow.com/q/12537617/119114). Can you try one of those, and see if this is the problem? Or just look at your Xcode build settings, and see if you're configured to build for only one architecture? – Nate Oct 19 '12 at 04:33
  • It turned out to be a moot point; after an extended period of app failure my app started working normally for no reason. Thanks anyway! – spamguy Oct 19 '12 at 12:45
  • Architectures in the fat file: MyApp.app/MyApp are: armv7 (cputype (12) cpusubtype (11)) does it means it is a fat file,right? but with only one architecture? – Itay Levin Nov 05 '12 at 06:27
  • 1
    @ItayLevin, if it **only** lists `armv7`, then it's not a fat binary. CPU type and subtype are just two different descriptors, but `armv7` is the only *architecture* I see in what you posted, so it's not fat. – Nate Nov 05 '12 at 07:11
  • 1
    "cputype (12) cpusubtype (11)" is armv7s. `xcrun -sdk iphoneos lipo -info ...` will dump the value properly. A radar exists for `/usr/bin/lipo`'s inability to recognize the processor and architecture. – jww Jul 07 '13 at 11:25
  • 1
    I can confirm the updated ldid appears to sign fat binaries. Don't forget to chmod your binary also with execute permissions. Lastly if you don't have a Mac you can accomplish this using Travis CI now as will be seen at https://github.com/OneBusAway/onebusaway-iphone shortly. – bbodenmiller Jul 28 '13 at 13:03
3

Starting from what seems Xcode 4.5 onward, maybe as early as 4.4 have not checked, in order to pseudo code sign using the ldid tool, you need to download and install 'Command Line Tools' from here or you can download it from within Xcode, Preferences->Downloads

Otherwise you will get errors like

  • util/ldid.cpp(584):
  • ./minimal/mapping.h(54): _assert(2:false)
  • util/ldid.cpp(567)
  • and so on

You still need to make sure it is not a "fat" binary and only armv7 as armv6 is no longer supported.

ldid -S ExampleApp

Omar
  • 492
  • 4
  • 10
0

The error assert(2:false) comes from the fact that HelloJB (not HelloJB.app) is write protected!

  1. Start Terminal.app
  2. Go to directory HelloJB.app
  3. chmod +aw HelloJB
  4. ldid -S HelloJB works !