您的位置:首页 > 移动开发

不通过AppStore,在iOS设备上直接安装应用程序的原理

2015-06-26 11:09 501 查看
通过itms-services协议,可以通过safari浏览器直接在iOS设备上安装应用程序。利用这种方式,只要在内网布置一个服务器,测试人员只需要通过测试设备的safari浏览器访问特定的url既可以实现安装,然后测试了。(PS:越狱设备也可以)

itms- services协议需要一个plist配置文件。如果要实现上面图示的功能,需要的文件有:一个ipa文件,一个plist文件,一个html文件和一 个图片文件。其中,最主要的,就是plist文件。通过shell脚本,我们可以让其自动为我们生成plist文件和html文件,并且在xcode工程 中的ipa文件和程序图标文件复制一份,放到一起。

《xcode自动打ipa包脚本》学习地址:http://webfrogs.me/2012/09/19/buildipa/

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>items</key>   
   <array>   
       <dict>   
           <key>assets</key>   
           <array>   
               <dict>   
                   <key>kind</key>   
                   <string>software-package</string>   
                   <key>url</key>   
                   <string>ipa包的下载地址,如:http://www.tammy.com:450/static/ios/(targetname)_(version)_build(buildversion)_yyyyMMdd.ipa</string>   
               </dict>   
           </array>   
           <key>metadata</key>   
           <dict>   
               <key>bundle-identifier</key>   
               <string>应用程序中的<span style="font-family:FangSong_GB2312">bundle-identifier</span><span style="font-family:FangSong_GB2312"></string></span>   
               <key>bundle-version</key>   
               <string>版本号</string>   
               <key>kind</key>   
               <string>software</string>   
               <key>subtitle</key>   
               <string>子标题</string>   
               <key>title</key>   
               <string>软件名称</string>   
           </dict>   
       </dict>   
   </array>   
</dict>   
</plist>


html文件范例如下:
<span style="font-size:12px"><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">   
<html>   
<head>   
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">   
  <meta http-equiv="Content-Style-Type" content="text/css">   
  <title>测试包安装</title>   
</head>   
<body>   
<br>   
<div style="position:absolute;left:200px" width=400><a href="../index.html">返回</a></div>   
    <h1 align="center">开发版(TRUNK)</h1>   
    <table align="center" border=1 width=400>   
    <tr height=60>   
        <th colspan=2><h2>标题</h2></th>   
    </tr>   
    <tr height=60 align="center">   
        <td width=200><a href="itms-services://?action=download-manifest&url=</span><span style="font-size:10px"><span style="font-family:FangSong_GB2312">http://www.tammy.com:450/static/ios/****.plist</span><span style="font-family:FangSong_GB2312">"><h2>Install</h2></a></td></span></span><span style="font-size:12px">   
        <td width=200><a href="</span><pre name="code" class="html" style="color:rgb(34,34,34); line-height:22px">http://www.tammy.com:450/static/ios/(targetname)_(version)_build(buildversion)_yyyyMMdd.ipa</pre>"><h2>Download</h2></a></td></tr>    </table><br></body></html>


不通过App Store,直接安装应用程序的实现步骤:

1、设置签名

利用developer profile或者adhoc distribution profile签名app,注意,不能使用distribution profile方式签名;个人开发者证书只能在100个设备中实现无线安装。

2、生成arichive

菜单:product->archive,完成后可以在organizer中看到生成的arichive。

3、生成ipa

选择刚刚生成的arichive,点击“Distribute...",弹出如下图界面,选择第二个,点“next”,设置相关参数,一 定要勾选“save for enterprise distribution”。application url,是生成的ipa在服务器的位置;title是安装过程中出现的标题;large image url 和 smal image url是安装过程中出现的图标。点击保存,将生成两个文件:***.ipa和***.plist。

4、服务器部署

将生成的***.ipa和***.plist文件部署到服务器,同时在服务器生成一个html文件,目的是点击后打开一个链接,这样ios设备就会执行指令自动安装app了。要打开的链接内容如下:

itms-services://?action=download-manifest&url=http://www.tammy.com:450/static/ios/****.plist
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: