歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> iOS6 代碼實現安裝ipa

iOS6 代碼實現安裝ipa

日期:2017/3/1 9:54:38   编辑:Linux編程

在使用91助手的時候,下載應用的時候並沒有彈出是否安裝應用,所以91助手的實現有可能是通過代碼來安裝應用的,經過這兩天的摸索(貌似效率有些低啊),最後實現了,整理了些資料,分享一下,如果有補充的,歡迎評論.

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

一、破解Xcode,將項目生成無簽名的app文件,這步很重要,若xcode不破解,使用ldid對權限進行修改時將卡住並失敗。
Xcode破解鏈接:
<最簡單破解Xcode,切換破解狀態> http://www.linuxidc.com/Linux/2013-07/88019.htm


二、使用private API,加載MobileInstallation 庫,調用安裝方法
h文件
#import "dlfcn.h"
typedefint (*MobileInstallationInstall)(NSString *path, NSDictionary *dict, void *na, NSString *path2_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>

在終端中輸出命令:
1 ldid -Sentitlements.xml InstallApp.app/InstallApp

查看結果:
ldid -e InstallApp.app/InstallApp

四、將app打包成ipa
新建一個文件夾,命名為“Payload”。將剛剛添加好權限的APP文件放到這個文件夾中。右鍵“壓縮Payload”,得到一個“.zip”文件,將這個ZIP文件的後綴名改為“.ipa”。

本文要用到的ldid附件下載:

**************************************************************

免費下載地址在 http://linux.linuxidc.com/

用戶名與密碼都是www.linuxidc.com

具體下載目錄在 /2013年資料/7月/29日/iOS6 代碼實現安裝ipa

下載方法見 http://www.linuxidc.com/Linux/2013-07/87684.htm

**************************************************************

Copyright © Linux教程網 All Rights Reserved