iOS How to use Entitlement.plist to specify property of my app

♀尐吖头ヾ 提交于 2019-11-28 09:27:07

I see two problems/questions in your post:

1) you get the error

'Receiver type 'UIApplication' for instance message does not declare a method with selector 'launchApplicationWithIdentifier:suspended:''

Is that a compiler error? It sounds like maybe it is. Here's the thing. There's plenty of objective-c classes in the set of Public Frameworks that still have some private methods in them. Thus, in the normal headers (.h files) for the public frameworks, those private methods won't be listed. But, they're there in the dynamic libraries. If you want to build an app that uses these, then one way to solve the problem is to find a copy of the full header.

For example, here's a copy of the full UIApplication.h header.

Then, you can copy the declaration of the private methods, and in your own code, declare them like so:

// Used to disable warning for non-public methods
@interface UIApplication (Extensions)
  - (BOOL)launchApplicationWithIdentifier:(id)identifier suspended:(BOOL)suspended;
@end

That should stop the compiler from complaining that the private method doesn't exist.

For the future, you should read about class-dump, which is a tool that you can run on the public or private frameworks in the SDK, and reverse generate headers like the one above, yourself. They'll change with every release of the SDK, so it's good to be able to generate them yourself.

2) you ask about using entitlements without code signing.

First, read what Saurik originally wrote about it here. 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.springboard.launchapplications</key>
    <true/>
  </dict>
</plist>

Be careful. I have found ldid on the internet in a couple places. I'm really not sure which one is the right one. I recall that once, I tried to do this, and the version of ldid I was using did not work for signing entitlements. I downloaded ldid from another source, and then it worked. So, beware.

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