Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
286 views
in Technique[技术] by (71.8m points)

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

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...