SBSLaunchApplicationWithIdentifier 运行app报错

我在iphone用theos直接编译tool代码,想直接通过bundle ID来运行app,部分代码如下

int (*openApp)(CFStringRef, Boolean);
void* sbServices = dlopen("/System/Library/PrivateFrameworks/SpringBoardServices.framework/SpringBoardServices", RTLD_LAZY);
openApp= (int(*)(CFStringRef, Boolean))dlsym(sbServices,"SBSLaunchApplicationWithIdentifier");
int result = openApp(CFSTR("com.ucweb.iphone"), false);
CFShow(SBSApplicationLaunchingErrorString(result));
dlclose(sbServices);

运行后返回错误
security policy error

百度说是
Provisioning Profiles过期(security policy error)但是都是在xcode上的,我在iphone上直接使用theos也会有这个问题吗 ?还是其他的原因呢?我该如何修改呢 ?
谢谢各位大侠,帮忙

你是在哪个进程中调用这个函数的?

狗神,你说对了,直中要害,这个东西要在SpringBoard中调用才行,其他位置调用就会失败

这个函数位于SpringBoardServices.framework中,理论上是只服务于SpringBoard的。我不确定给其他App添加一些entitlements,能否调用这个函数,你可以试试

你好,怎么tool在springboard中运行呢,或者还是其他什么方式,求教。

添加 Entitlements.plist 文件, 文件内容如下


<?xml version="1.0" encoding="UTF-8"?>
<!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>

然后在MakeFile中添加

TOOL_NAME_CODESIGN_FLAGS = -SEntitlements.plist

1 个赞

正解,可用!
有一个疑问:SBSLaunchApplicationWithIdentifier这个方法跟 - [LSApplicationWorkspace openApplicationWithBundleID:] 有啥区别?