I'm using Jailbreak + Appsync + iOS5.0.1 device (without a developer license but with some tricks I can run my app on the device)
Now I want to use a private API launchApplicationWithIdentifier:suspended:. So I need to add
<key>com.apple.springboard.launchapplications</key>
<true/>
to myApp.entitlements.plist file. Then it should work but I still got the error
'Receiver type 'UIApplication' for instance message does not declare a method
with selector 'launchApplicationWithIdentifier:suspended:''
Then I found someone said, code signing must be enable if I want to use Entitlements.plist. Is it true? I must have a developer license?
Or is there any other way to use this method? I read some method about how to use private API. It seems difficult. I'm new to iOS development.
Thank you.
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.
来源:https://stackoverflow.com/questions/11069330/ios-how-to-use-entitlement-plist-to-specify-property-of-my-app