How do I change my iOS applications' entitlements?

10,741

For a jailbreak app/entitlement, you need to do something like this. First, create a file named entitlements.xml (or whatever you like):

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>com.apple.backboard.client</key>
    <true/>
  </dict>
</plist>

You can add more entitlements if you need. This example file just grants the app the com.apple.backboard.client entitlement.

It doesn't really matter where you put this file. The key is:

  1. You will need to modify Xcode's SDKSettings.plist file, as shown here. CODE_SIGNING_REQUIRED should be set to NO.
  2. Do not code sign your app in Xcode. In Build Settings, make sure the code sign identity is set to Don't Code Sign.
  3. After you then Build your app for the iOS Device (not Simulator!), then go to the directory on your Mac where the output files are located. For an app named HelloWorld, you're looking for the HelloWorld.app folder. It can differ depending on your configuration, so I won't bother trying to tell you where that is. If in doubt, use the command line find command.
  4. Download ldid pre-built from this location, or as source from here.
  5. Copy the entitlements.xml file into the same directory as where HelloWorld.app is. (Note: you don't have to have it here ... if you put it somewhere else, just adjust the command line I show you below).
  6. Change directory to the directory where your entitlements.xml file is.
  7. Fake code-sign with this command:
$ldid -Sentitlements.xml HelloWorld.app/HelloWorld

After that point, you'll need to transfer the entire HelloWorld.app folder to install the app on your device. There's many ways to do that, and it sounds like you already have a way.

I have this whole process setup with a script, to make it easier.

Note: I am not stating whether or not this entitlement is the correct entitlement to use for the BKSDisplayServicesSetScreenBlanked() call on iOS 6. I haven't tested that. I do know that this entitlement works to allow you to use SBDimScreen() on lower iOS versions. But, this answer is just a description of how to add this kind of entitlement for a jailbreak app.

Share:
10,741
zzzzz
Author by

zzzzz

Updated on June 28, 2022

Comments

  • zzzzz
    zzzzz almost 2 years

    I need to run the following code to turn off my iphone screen .

    On iOS6:

    void (*BKSDisplayServicesSetScreenBlanked)(BOOL blanked) = (void (*)(BOOL blanked))dlsym(RTLD_DEFAULT, "BKSDisplayServicesSetScreenBlanked");
    

    and then use:

    BKSDisplayServicesSetScreenBlanked(1); // 1 to dim, 0 to undim
    

    It doesnt work. Somebody told me that I need com.apple.backboard.client entitlements for this to work on my iphone. I dont know how to set these entitlements. I have seen several ways to set entitlements but they are very confusing to me, like this one.

    Yes, you do need to code sign the entitlements. But, no, it doesn't have to be with an Apple certificate on jailbroken phones. You can fake code sign, by downloading the ldid executable, and doing

    cd MyAppName.app 
    ldid -Sentitlements.xml MyAppName
    

    assuming your app is named MyAppName and you made the entitlements file entitlements.xml. I believe that this entitlements file would work for you, if you fake code-signed it with ldid.

    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
     "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0">
       <dict>
         <key>com.apple.backboard.client</key>
         <true/>
       </dict> 
    </plist>
    

    Even with the above method, where do i place the above entitlements file?

  • Nate
    Nate over 11 years
    (-1) this answer is wrong, or woefully incomplete. This normal process for adding entitlements does not work for adding this kind of entitlement for a jailbreak app.
  • zzzzz
    zzzzz over 11 years
    Can I get your skype id please? So I could email you next time I have a jailbreak type question
  • zzzzz
    zzzzz over 11 years
    I cant sign it using ldid command.it says -bash: -Sentitlements.xml: command not found
  • Nate
    Nate over 11 years
    I can't tell what the error message is, because you haven't used formatting. Please surround the exact output with tick marks (top left of most keyboards). It would also help if you showed exactly what command you tried (also formatted with code tick marks).
  • zzzzz
    zzzzz over 11 years
    I am currently in the directory where screenoffios6.app is placed.entitlements file is also placed in the same directory where i run the command. Now the command I am using is administrators-Mac-mini-3:debug-iphoneos me$ $ldid -s entitlements.xml screenoffios6.app/screenoffios6 It returns the following error -bash: -s: command not found
  • Nate
    Nate over 11 years
    And, you really need to type the commands as I list them. The -S is uppercase, not lowercase, and there's no space between it and entitlements.xml.
  • zzzzz
    zzzzz over 11 years
    Once I put the ./ldid i get the following error -bash: $./ldid: No such file or directory I used the following command ./ldid -Sentitlements.xml screenoffios6.app/screenoffios6
  • zzzzz
    zzzzz over 11 years
    you are right.I was accidentally typing a $ infront of the command.The command now works but I am getting the following message. codesign_allocate: object: screenoffios6.app/screenoffios6 malformed object (unknown load command 10) util/ldid.cpp(584): _assert(0:WEXITSTATUS(status) == 0) Trace/BPT trap: 5
  • Nate
    Nate over 11 years
    Please navigate in Terminal to the directory where your build product is, and go into screenoffios6.app/. Inside that directory, issue the command file screenoffios6 and tell me what the output is (please surround by ticks in your comment). Also, which version of ldid (which link I showed in my answer) did you use to get ldid?
  • zzzzz
    zzzzz over 11 years
    I used the first link to download ldid and file screenoffios6 returned the following output screenoffios6: Mach-O executable arm
  • Nate
    Nate over 11 years
    That looks ok, in terms of being one architecture only. Can you run this command: lipo -info screenoffios6 in the same directory? Your system might not have lipo, but hopefully it does.
  • zzzzz
    zzzzz over 11 years
    I got this output Non-fat file: screenoffios6 is architecture: armv7
  • Nate
    Nate over 11 years
    That should be good, too. At this point, I'm not quite sure what could be wrong. The only thing I can think of is to post your binary on some other site and link to it so I can download the screenoffios6 executable, and trying signing it myself. I would only need the executable, not any of the other resources needed to run your app (Info.plist, icons, etc.). That's all I can think to suggest at this point.
  • zzzzz
    zzzzz over 11 years
    mac version is mac osx 10.7.5
  • Nate
    Nate over 11 years
    Me, too. I dunno. That exact executable signs successfully for me. The only thing I can suggest is go back and try it again, taking care to type everything in exactly as I listed it. Or google for your error message ... similar error described here
  • Nate
    Nate over 11 years
    Also, maybe there's something I have installed that you don't. Try going to Xcode -> Preferences -> Downloads, and make sure Command Line Tools are installed.
  • Nate
    Nate over 11 years
    One more option is to not do ldid signing on your Mac, but transfer the unsigned executable to the device, along with the entitlements.xml file. Go into Cydia and search for ldid and install it on your phone. Then, at the (ssh) command line, navigate to where you install your app, and try the ldid -Sentitlements.xml screenoffios6 command again, on the device.
  • 0x8BADF00D
    0x8BADF00D over 10 years
    I can confirm that it does not work for jailbreak app. (iOS 7.0.4)