iOS6 代码实现安装ipa

[http://chenjohney.blog.51cto.com/4132124/1256610]
iOS6 代码实现安装ipa
2013-07-24 23:25:47
原创作品,允许转载,转载时请务必以超链接形式标明文章  原始出处 、作者信息和本声明。否则将追究法律责任。 http://chenjohney.blog.51cto.com/4132124/1256610

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

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

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

Xcode破解链接:

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


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

h文件

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

m文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
- ( 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,粘贴以下内容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<? 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 >

在终端中输出命令:

1
ldid -Sentitlements.xml InstallApp.app /InstallApp

查看结果:

1
ldid -e InstallApp.app /InstallApp

四、将app打包成ipa

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值