How do I change my iOS applications' entitlements?

馋奶兔 提交于 2019-11-26 03:39:44

问题


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?


回答1:


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.




回答2:


The entitlements are set in either the Xcode project file or set in the entitlements file that the Xcode project chooses.

Look in the project settings in "Summary" or "Build Phases" for the setting or the name of the entitlements file



来源:https://stackoverflow.com/questions/14871748/how-do-i-change-my-ios-applications-entitlements

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!