iOS 6.x open command line on jailbreak(iOS 6.x 在越狱时打开命令行)
问题描述
在 iOS 6.x 之前,我使用 open package_id 在 iOS 设备上从命令行打开应用程序.在 iOS 6.x 上,如果我使用此命令 SpringBoard 会崩溃.Open 可从 BigBoss 获得,作者是 Conrad Kramer.
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.
BigBoss 的 open 命令是否有替代或修复方法?
Is there an alternative or a fix for the open command from BigBoss?
推荐答案
更新:
看起来原来的 /usr/bin/open 已经在 Cydia 上针对 iOS 6 进行了更新,所以我建议你先尝试一下.
Update:
It looks like the original /usr/bin/open has been updated for iOS 6 on Cydia, so I recommend you try that first.
我也想念open!但是,在它为 iOS 6 更新之前,您可以构建自己的非图形应用程序(只是一个 main 程序,而不是 UIApplicationMain())并做同样的事情自己动手.
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.
我将跳过从 int main(int argc, char *argv[] 解析命令行参数,但是一旦你知道 Bundle Id (CFBundleIdentifier),打开SpringBoardServices私有框架,用它来启动应用:
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);
}
此代码需要 com.apple.springboard.launchapplications 授权,您的命令行程序才能以 mobile 用户的身份成功使用它.查看此处以添加权利.您的可执行文件需要一个 entitlements.xml 文件,如下所示:
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>
然后用签名
ldid -Sentitlements.xml MyCommandLineTool
注意:我尚未对此进行测试,但 此答案表明使用权利的替代方法是以 root 身份运行命令.
Note: I haven't tested this, but this answer states that an alternative to using entitlements is to run the command as root.
这篇关于iOS 6.x 在越狱时打开命令行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:iOS 6.x 在越狱时打开命令行
基础教程推荐
- 如何从 logcat 中删除旧数据? 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
