xcode 如何更改我的 iOS 应用程序的权限?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14871748/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I change my iOS applications' entitlements?
提问by zzzzz
I need to run the following code to turn off my iphone screen .
我需要运行以下代码来关闭我的 iphone 屏幕。
On iOS6:
在 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.
它不起作用。有人告诉我,我需要com.apple.backboard.client
授权才能在我的 iphone 上使用它。我不知道如何设置这些权利。我已经看到了几种设置权利的方法,但它们对我来说非常混乱,就像这个一样。
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.
是的,您确实需要对权利进行代码签名。但是,不,它不必在越狱手机上使用 Apple 证书。您可以通过下载 ldid 可执行文件来伪造代码签名,然后执行
cd MyAppName.app ldid -Sentitlements.xml MyAppName
假设您的应用程序名为 MyAppName,并且您创建了权利文件 entitlements.xml。我相信这个权利文件对你有用,如果你用 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?
即使使用上述方法,我在哪里放置上述权利文件?
回答by Nate
For a jailbreak app/entitlement, you need to do something like this. First, create a file named entitlements.xml
(or whatever you like):
对于越狱 app/entitlement,你需要做这样的事情。首先,创建一个名为entitlements.xml
(或任何你喜欢的名字)的文件:
<!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 moreentitlements if you need. This example file just grants the app the com.apple.backboard.client
entitlement.
如果需要,您可以添加更多权利。此示例文件仅授予应用程序com.apple.backboard.client
权利。
It doesn't really matter whereyou put this file. The key is:
你把这个文件放在哪里并不重要。关键是:
- You will need to modify Xcode's
SDKSettings.plist
file, as shown here.CODE_SIGNING_REQUIRED
should be set toNO
. - Do not code sign your app in Xcode. In Build Settings, make sure the code sign identity is set to Don't Code Sign.
- After you then Buildyour 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 theHelloWorld.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 linefind
command. - Download
ldid
pre-built from this location, or as source from here. - Copy the entitlements.xml file into the same directory as where
HelloWorld.app
is. (Note: you don't haveto have it here ... if you put it somewhere else, just adjust the command line I show you below). - Change directory to the directory where your entitlements.xml file is.
- Fake code-sign with this command:
- 您将需要修改 Xcode 的
SDKSettings.plist
文件,如下所示。CODE_SIGNING_REQUIRED
应设置为NO
. - 不要在 Xcode 中对您的应用程序进行代码签名。在Build Settings 中,确保代码签名标识设置为Don't Code Sign。
- 在为iOS 设备(不是模拟器!)构建应用程序后,转到 Mac 上输出文件所在的目录。对于名为 的应用程序,您正在查找文件夹。它可能因您的配置而异,所以我不会费心告诉您它在哪里。如果有疑问,请使用命令行命令。
HelloWorld
HelloWorld.app
find
ldid
从此位置下载预构建,或从此处下载作为源。- 将 entitlements.xml 文件复制到与 where
HelloWorld.app
is相同的目录中。(注:你不要有在这里拥有它......如果你把它放在别的地方,只是调整的命令行我告诉你下面)。 - 将目录更改为 entitlements.xml 文件所在的目录。
- 使用此命令伪造代码签名:
$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.
之后,您需要传输整个 HelloWorld.app 文件夹以在您的设备上安装该应用程序。有很多方法可以做到这一点,而且听起来你已经有办法了。
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 howto add this kind of entitlement for a jailbreak app.
注意:我没有说明此权利是否是用于BKSDisplayServicesSetScreenBlanked()
在 iOS 6 上进行呼叫的正确权利。我尚未对此进行测试。我确实知道此权利可以让您SBDimScreen()
在较低的 iOS 版本上使用。但是,这个答案只是描述了如何为越狱应用程序添加这种权利。
回答by Walt Sellers
The entitlements are set in either the Xcode project file or set in the entitlements file that the Xcode project chooses.
权利在 Xcode 项目文件中设置或在 Xcode 项目选择的权利文件中设置。
Look in the project settings in "Summary" or "Build Phases" for the setting or the name of the entitlements file
在“摘要”或“构建阶段”中的项目设置中查找权利文件的设置或名称