在使用91助手的时候,下载应用的时候并没有弹出是否安装应用,所以91助手的实现有可能是通过代码来安装应用的,经过这两天的摸索(貌似效率有些低啊),最后实现了,整理了些资料,分享一下,如果有补充的,欢迎评论.

注:需要在xcode中先把Command Line Tools装好。

一、破解Xcode,将项目生成无签名的app文件,这步很重要,若xcode不破解,使用ldid对权限进行修改时将卡住并失败。

Xcode破解链接:

<最简单破解Xcode,切换破解状态> http://chenjohney.blog.51cto.com/blog/4132124/1256600


二、使用private API,加载MobileInstallation 库,调用安装方法

h文件

#import "dlfcn.h"typedefint (*MobileInstallationInstall)(NSString *path, NSDictionary *dict, void *na, NSString *path3_equal_path_maybe_no_use);

m文件

- (int)IPAInstall:(NSString *)path{ void *lib = dlopen("/System/Library/PrivateFrameworks/MobileInstallation.framework/MobileInstallation", RTLD_LAZY); if (lib) { MobileInstallationInstall pMobileInstallationInstall = (MobileInstallationInstall)dlsym(lib, "MobileInstallationInstall"); if (pMobileInstallationInstall){ int ret = pMobileInstallationInstall(path, [NSDictionarydictionaryWithObject:@"User"forKey:@"ApplicationType"], nil, path); dlclose(lib); return ret; } } return -1;}


三、将项目真机调试生成app, 使用ldid 修改app权限,ldid在文章中的附件中可以下载

新建一个配置文件entitlements.xml,粘贴以下内容

<?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.private.mobileinstall.allowedSPI</key> <array> <string>Install</string> <string>Browse</string> <string>Uninstall</string> <string>Archive</string> <string>RemoveArchive</string> </array> </dict></plist>

在终端中输出命令:

ldid -Sentitlements.xml InstallApp.app/InstallApp

查看结果:

ldid -e InstallApp.app/InstallApp

四、将app打包成ipa

新建一个文件夹,命名为“Payload”。将刚刚添加好权限的APP文件放到这个文件夹中。右键“压缩Payload”,得到一个“.zip”文件,将这个ZIP文件的后缀名改为“.ipa”。


附件:http://down.51cto.com/data/2363204