前言
在iOS應用的實際開發中,我們會遇到給產品經理或者測試team人員安裝應用到他們手機上的需求。這時候直接拿他們手機連你的電腦安裝顯然不切現實。這時候我應該這么做?如果他們能直接用ipa文件安裝應用的話,我們就只需要每次提供他們ipa文件就好了。當然這個是可以的,蘋果容許用itms-services協議來直接在iOS設備上安裝應用程序。那這個基于網頁安裝應用程序的方法,到底應該怎么做呢?好的,下面我就會詳細說明具體步驟
詳細步驟
- 你首先需要生成一個ipa文件(例如ToDo.ipa),最簡單的方法就是用xcode Product -> Archive。當然你也可以通過xcodebuild和xcrun命令(這個我下篇文章會詳細說明使用xcodebuild和xcrun,通過腳本來實現每天自動打包應用程序(Daily Build),然后發郵件通知相關人員,有新版本可以測試)
- 把ipa文件放到一個server上,提供一個網址可以直接訪問這個文件(例如https://dl.dropboxusercontent.com/s/8as5gtd8yqwxh8v/ToDo.ipa )。我為了簡單起見,就用DropBox了,大家可以考慮用阿里云,百度云等等
- 生成plist文件(例如ToDoOTA.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文件的下載地址(例如,https://dl.dropboxusercontent.com/s/8as5gtd8yqwxh8v/ToDo.ipa)</string>
</dict>
</array>
<key>metadata</key>
<dict>
<key>bundle-identifier</key>
<string>這里填寫Bundle ID</string>
<key>bundle-version</key>
<string>這里填寫版本號(例如1.5.0)</string>
<key>kind</key>
<string>software</string>
<key>title</key>
<string>這里填寫應用標題(例如ToDo)</string>
</dict>
</dict>
</array>
</dict>
</plist>
- 把plist文件放到一個server上,并提供一個網址可以訪問這個文件(例如https://dl.dropboxusercontent.com/s/xn1sef46n659ms5/todo-ota.plist )。特別注意plist文件必須是https的連接
- 生成html文件(例如todo.html),并部署這個網頁到你的網站(例如 http://blog.zhoudengfeng.com/apps/todo.html ).
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta http-equiv="Content-Language" content="zh-CN" />
<style type="text/css">
body{text-align:center;padding-top:100}
div{width:778px;margin:0 auto;background:#fff;text-align:left;}
</style>
</head>
<body text-align=center>
<h1>ToDo</h1>
<p>This is a very simple to-do list app. It's easy to create, complete and delete your to-dos. It makes your life more effective and efficient.</p>
<p><a href="itms-services://?action=download-manifest&url=https://dl.dropboxusercontent.com/s/xn1sef46n659ms5/todo-ota.plist">Install ToDo v1.5.0</a></p>
</a></p>
</body>
</html>
- 現在在瀏覽器中打開你的html網頁,點擊你網頁上面的Install,就可以直接安裝應用程序了
總結
- 保存plist文件的server一定要支持https
- html文件我寫的很簡單,其中最重要的就是下面的這段代碼, 其它的都不重要
<p><a href="itms-services://?action=download-manifest&url=https://dl.dropboxusercontent.com/s/xn1sef46n659ms5/todo-ota.plist">Install ToDo v1.5.0</a></p>
- 大家如果想看下安裝的具體效果,可以點擊ToDo Install來安裝體驗。順便打個廣告,這個ToDo是我根據自己需求的開發的一個很簡潔很實用的待辦事項提醒的APP,你可以點擊直接安裝,也可以去AppStore下載ToDo - To Do List & Tasks by dengfeng zhou。歡迎大家安裝使用,如果愿意提出寶貴意見更好