Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么不能在我真正的ipad mini4(ios10.2)上使用代码安装/卸载应用程序_Ios_Objective C - Fatal编程技术网

为什么不能在我真正的ipad mini4(ios10.2)上使用代码安装/卸载应用程序

为什么不能在我真正的ipad mini4(ios10.2)上使用代码安装/卸载应用程序,ios,objective-c,Ios,Objective C,我从互联网上搜索,得到了下面的代码,它在模拟器上运行良好,但在我的iPadMini4(iOS10.2,已经越狱)上不起作用 --不工作意味着它无法安装/卸载其他应用程序。若我从Xcode调试,我可以看到如下消息。 LaunchServices:com.apple.lsd.modifydb服务接收到断开事件 我还尝试使用ldid添加签名,同样的错误 我的代码如下: IPAResult installApp(NSString *ipaPath, NSString *ipaId) { IPAR

我从互联网上搜索,得到了下面的代码,它在模拟器上运行良好,但在我的iPadMini4(iOS10.2,已经越狱)上不起作用

--不工作意味着它无法安装/卸载其他应用程序。若我从Xcode调试,我可以看到如下消息。
LaunchServices:com.apple.lsd.modifydb服务接收到断开事件

我还尝试使用ldid添加签名,同样的错误

我的代码如下:

IPAResult installApp(NSString *ipaPath, NSString *ipaId) {
    IPAResult ret = -1;
    if (kCFCoreFoundationVersionNumber < 1140.10) {
        void *lib = dlopen(KEY_SDKPATH, RTLD_LAZY);
        if (lib) {
            MobileInstallationInstall install = (MobileInstallationInstall)dlsym(lib, "MobileInstallationInstall");
            if (install)
                ret = install(ipaPath, [NSDictionary dictionaryWithObject:KEY_INSTALL_TYPE forKey:@"ApplicationType"], 0, ipaPath);
            dlclose(lib);
        }
    } else {
        NSLog(@"path:%@,id:%@", ipaPath, ipaId);
        Class LSApplicationWorkspace_class = objc_getClass("LSApplicationWorkspace");
        if (LSApplicationWorkspace_class) {
            LSApplicationWorkspace *workspace = [LSApplicationWorkspace_class performSelector:@selector(defaultWorkspace)];

            if (workspace && [workspace installApplication:[NSURL fileURLWithPath:ipaPath] withOptions:[NSDictionary dictionaryWithObject:ipaId forKey:@"CFBundleIdentifier"]])
                ret = 0;

        }
    }
    return ret;
}

BOOL uninstallApplication(NSString *appIdentifier) {
    if (kCFCoreFoundationVersionNumber < 1140.10) {
        void *lib = dlopen(KEY_SDKPATH, RTLD_LAZY);
        if (lib) {
            MobileInstallationUninstall uninstall = (MobileInstallationUninstall)dlsym(lib, "MobileInstallationUninstall");
            if (uninstall)
                return 0 == uninstall(appIdentifier, nil, nil);
            dlclose(lib);
        }
    } else {
        Class LSApplicationWorkspace_class = objc_getClass("LSApplicationWorkspace");
        if (LSApplicationWorkspace_class) {
            LSApplicationWorkspace *workspace = [LSApplicationWorkspace_class performSelector:@selector(defaultWorkspace)];
            if (workspace && [workspace uninstallApplication:appIdentifier withOptions:nil])
                return YES;
        }

    }
    return NO;
}
IPAResult installApp(NSString*ipaPath,NSString*ipaId){
IPASult ret=-1;
如果(KCFCoreFoundation版本号<1140.10){
void*lib=dlopen(KEY\u SDKPATH,RTLD\u LAZY);
if(lib){
MobileInstallationInstall安装=(MobileInstallationInstall)dlsym(lib,“MobileInstallationInstall”);
如果(安装)
ret=install(ipaPath,[NSDictionary Dictionary Dictionary WithObject:KEY_install_TYPE forKey:@“ApplicationType”],0,ipaPath);
dlclose(lib);
}
}否则{
NSLog(@“路径:%@,id:%@”,ipaPath,ipaId);
类LSApplicationWorkspace_Class=objc_getClass(“LSApplicationWorkspace”);
if(LSApplicationWorkspace_类){
LSApplicationWorkspace*工作空间=[LSApplicationWorkspace_类性能选择器:@selector(defaultWorkspace)];
if(工作区和[workspace installApplication:[NSURL fileURLWithPath:ipaPath]带选项:[NSDictionary Dictionary dictionaryWithObject:ipaId forKey:@“CbundleIdentifier”])
ret=0;
}
}
返回ret;
}
BOOL卸载应用程序(NSString*appIdentifier){
如果(KCFCoreFoundation版本号<1140.10){
void*lib=dlopen(KEY\u SDKPATH,RTLD\u LAZY);
if(lib){
MobileInstallationUninstall=(MobileInstallationUninstall)dlsym(lib,“MobileInstallationUninstall”);
如果(卸载)
返回0==卸载(appIdentifier,nil,nil);
dlclose(lib);
}
}否则{
类LSApplicationWorkspace_Class=objc_getClass(“LSApplicationWorkspace”);
if(LSApplicationWorkspace_类){
LSApplicationWorkspace*工作空间=[LSApplicationWorkspace_类性能选择器:@selector(defaultWorkspace)];
if(工作区&&[workspace-uninstallApplication:appIdentifier with-options:nil])
返回YES;
}
}
返回否;
}
我使用的签名是:

<key>get-task-allow</key>
<true/>
<key>com.apple.private.mobileinstall.allowedSPI</key>
<array>
    <string>CheckCapabilitiesMatch</string>
    <string>InstallForLaunchServices</string>
    <string>UninstallForLaunchServices</string>
</array>
<key>com.apple.backboardd.launchapplications</key>
<true/>
<key>com.apple.springboard.openapplications</key>
<true/>
get任务允许
com.apple.private.mobileinstall.allowedSPI
检查能力匹配
InstallForLaunchServices
卸载ForLaunchServices
com.apple.backboardd.launchapplications
com.apple.springboard.openapplications

iOS应用程序是沙盒,除了自身之外,不能触摸任何东西。这包括操作系统,以及您的情况下的其他应用程序

你将无法实现你想要实现的目标,这受到操作系统的限制