Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

iOS 6.x open command line on jailbreak

Before iOS 6.x, I used open package_id to open a app from command line on a iOS device. On iOS 6.x if i use this command SpringBoard crashes. Open is available from BigBoss and the author is Conrad Kramer.

Is there an alternative or a fix for the open command from BigBoss?

See Question&Answers more detail:os

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

1 Answer

0 votes
by (71.8m points)

Update:

It looks like the original /usr/bin/open has been updated for iOS 6 on Cydia, so I recommend you try that first.


Original Answer:

I miss open, too! But, until it gets updated for iOS 6, you can just build your own non-graphical app (just a main program, not a UIApplicationMain()) and do the same thing yourself.

I'll skip over parsing command line arguments from int main(int argc, char *argv[], but once you know the Bundle Id (CFBundleIdentifier) of the app you want to open, open the SpringBoardServices private framework, and use it to launch the app:

#include <dlfcn.h>
#define SBSERVPATH "/System/Library/PrivateFrameworks/SpringBoardServices.framework/SpringBoardServices"

-(void) openApp: (NSString*) bundleId {

    // the SpringboardServices.framework private framework can launch apps,
    //  so we open it dynamically and find SBSLaunchApplicationWithIdentifier()
    void* sbServices = dlopen(SBSERVPATH, RTLD_LAZY);
    int (*SBSLaunchApplicationWithIdentifier)(CFStringRef identifier, Boolean suspended) = dlsym(sbServices, "SBSLaunchApplicationWithIdentifier");
    int result = SBSLaunchApplicationWithIdentifier((__bridge CFStringRef)bundleId, false);
    dlclose(sbServices);
}

This code requires the com.apple.springboard.launchapplications entitlement for your command line program to use it successfully, as the mobile user. See here for adding an entitlement. You'd need an entitlements.xml file for your executable, like this:

<!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>

And then sign it with

ldid -Sentitlements.xml MyCommandLineTool

Note: I haven't tested this, but this answer states that an alternative to using entitlements is to run the command as root.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...