4

[EDIT]I've jb my device. And I found the latest private APIs iOS-Runtime-Headers on Github.

I want to use private APIs in my app.

I found kennytm/iphone-private-frameworks on github but it only support iOS 3.x. While I'm working on iOS 5.0.1.

I also found some codes on Google iPhone development tools. But it really make me confused. I'm new to iPhone development.

What should I do to use

[[UIApplication sharedApplication] launchApplicationWithIdentifier:@"com.a.b" suspended:NO];

Someone can give me a direction or some examples. Thanks a lot.

Oleg Trakhman
  • 2,082
  • 1
  • 17
  • 35
wyp
  • 869
  • 3
  • 11
  • 23

1 Answers1

8

REQUIREMENTS

  1. Jailbroken iDevice
  2. Valid certificates/keys in your keychain and its associated provisioning profile. (If you aren't enrolled in the apple developer program, use this workaround: self sign my code and test on iphone in xCode)

MY SOLUTION

1) Enable Entitlements in your XCode project.

To add Entitlements to your project, select your project in project navigator, then on active Target -> Summary -> Entitlements -> check Enable entitlements check box. New file with name "YourProject.entitlements" would appear in project navigator right after.

2) Add folowing property to Entitlements.

Add entitlement property: com.apple.springboard.launchapplications of type Boolean with value YES

3) Since launchApplicationWithIdentifier:suspended: is private API, you need to explicitly declare it in order to build your app. Just add folowing code in appropriate place(s):

// Simply make declaration  inside a Category.
#import "BlahBlah.h"
@interface UIApplication (Undocumented)
    - (void) launchApplicationWithIdentifier: (NSString*)identifier suspended: (BOOL)suspended;
@end
....
@implementation BlahBlah
...

4) Build your project.

5) Copy YourProject.app into device's /Application folder (via SFTP, for example)

6) Respring or reboot iDevice.

7) ...

8) Profit!

SEE ALSO

Special API to launch an app from my application - another solution

What is the bundle identifier of apple's default applications in iOS?

Community
  • 1
  • 1
Oleg Trakhman
  • 2,082
  • 1
  • 17
  • 35
  • I've jb my device.I add this key to /Supporting Files/myAppName-Info.plist then build it. I got message as before. receiver type 'UIApplication' for instance message does not declare a method with selector 'launchApplicationWithIdentifier:suspended:'. – wyp Jun 15 '12 at 09:41
  • NOT in info.plist. In Entitlements. Also check my UPD, there's another solution which may be helpful – Oleg Trakhman Jun 15 '12 at 09:53
  • I'm working on iOS 5 and Xcode 4.2. The official document says entitlements.plist is no longer needed since iOS4. So I don't know where should I find this file and add these lines to it. But use 'codesign -d --entitlements -xxxx/Build/Products/Debug-iphoneos/MyApp.app' in shell, I can see entitlements.plist. I'm really new to iOS development. Sorry. Now I'm trying the way in your UPD. But with 'launchApplicationWithIdentifier', the project is still can't be compiled successfully. Thank you. – wyp Jun 16 '12 at 14:50
  • I added information how to add entitlements to your project in XCode 4. Yeah, entitlements not neccessary since XCode they are still need in some cases. I thought they are useful for iCloud but I'm not sure. – Oleg Trakhman Jun 16 '12 at 17:49
  • Hope you'll succeed, with that solution or another. I'll check my solution anyway (on monday). – Oleg Trakhman Jun 16 '12 at 17:58
  • It works. Then I add com.apple.springboard.launchapplications to myapp.entitlements, but I still got the ERROR:Receiver type 'UIApplication' for instance message does not declare a method with selector 'launchApplicationWithIdentifier:suspended:'. It seems that I must use a developer license(I don't have one for now). Someone says Entitlements.plist works only when 'Code Signing' is enable. – wyp Jun 17 '12 at 01:02
  • wyp, I have just checked my solution and IT WORKS JUST FINE. I even didn't change file permissions. I also have got a solution for this 'not declare a method with selector' issue, take a look on UPD Contact with me if you have faced any other issues. – Oleg Trakhman Jun 18 '12 at 10:44
  • You are so kindhearted. :-). Finally I succeed, use UPD2 way, I didn't enable Entitlements, instead, I package my app into a deb file to grant it root property, then it just works. I will try Entitlements way. – wyp Jun 19 '12 at 08:34
  • Apologies for resurecting an old thread, but I've been using this trick for a year or so now, I just uprgraded to IOS 7 and my application is no longer able to switch to safari using ... [[UIApplication sharedApplication]launchApplicationWithIdentifier:@"com.apple.mobilesafari" suspended:NO]; .... any idea how I can get this working again in IOS 7??? – Plasma Jan 27 '14 at 17:10
  • @Plasma Why don't you just try `[[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"http://google.com]]"`??? – Oleg Trakhman Jan 28 '14 at 15:51
  • Because I want to return to Safari without changing the page its on. My application is called from Safari via a URL scheme attached to my App. My app processes the URL in a few seconds then returns you to Safari so you can continue browsing. Currently with IOS 7 it pops my app, processes the URL then you have to manually switch back to Safari which is a real pain. I've also been looking at SBSLaunchApplicationWithIdentifier, but I can't get the code to compile with the SpringBoardServices headers in place. – Plasma Jan 28 '14 at 21:48