Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 934
wyp Avatar asked Jun 17 '12 06:06

wyp


People also ask

How do I check iOS app entitlements?

Check the Entitlements In Your Build Log and App You'll find the name of the provisioning profile Xcode used to sign your app in the invocation of the codesign tool's command-line parameters. This command prints a plist that contains all of the entitlements built into the app.

What is entitlement file in iOS?

Entitlements are special app capabilities and security permissions granted to applications that are correctly configured to use them. In iOS, apps run in a sandbox, which provides a set of rules that limit access between the application and certain system resources or user data.


1 Answers

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.

like image 115
Nate Avatar answered Oct 02 '22 06:10

Nate