我們都知道在apple的平台上要將iOS APP安裝到實機上有幾種方法:
(1)直接從mac電腦上的Xcode去Run
(2)上架到APP Store下載下來安裝
(3)利用Ad Hoc直接從網頁上下載來安裝
今天我們就是要來介紹第三種方法-Ad Hoc,在這邊就不多說之間的差異或者優缺點了
我們直接開始接學!
1.首先先到https://developer.apple.com/account/ios/certificate/
去申請一個Ad Hoc的iOS Provisioning Profiles
下載後雙擊進行安裝
2.回到Xcode,點開Project > info >Configurations
正常情況下應該只會看到Debug&Release
這時候我們按下“+”新增一個Ad-Hoc
3.切換到TARGETS部分,點選BuildSettings>CodeSigning,會看到多了Ad Hoc那一欄
這時候就選取iPhone Distribution:XXX,也就是你所申請發佈用的Certificate
4.Product > Scheme>Edit Scheme
因為接下來會到Archive匯出ipa檔,所以將Build Configuration設成Ad-Hoc
5.接下來將裝置選成Generic iOS Device(就像是要發佈到App Store那樣)
點選右邊 Export...
然後再點選 Save for Ad Hoc Deployment
然後就照著步驟走就會產生出一個ipa檔!
那接下來呢我們就是要把ipa檔上傳到網路上,然後產生Url 讓測試者下載安裝囉!
這邊我選用的也是Dropbox的方式
6.將產生出來的ipa檔上傳到Dropbox,並取得檔案連結的Url
然後將這一段Url:
https://www.dropbox.com/s/2vxxxxxxxxxxxxx/TestAuto.ipa?dl=0
改成:
https://dl.dropboxusercontent.com/s/2vxxxxxxxxxxxxx/TestAuto
7.之後利用Xcode新增一個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文件的url**</string>
</dict>
</array>
<key>metadata</key>
<dict>
<key>bundle-identifier</key>
<string>**bundle id(com.xxx.xxx)**</string>
<key>bundle-version</key>
<string>**版本號碼(version)**</string>
<key>kind</key>
<string>software</string>
<key>title</key>
<string>**你App的名稱**</string>
</dict>
</dict>
</array>
</dict>
</plist>
編輯完畢後儲存成manifest.plist,並將這個檔案上傳到dropbox,
然後重複第6步驟的方式,取得Url
8.建立html讓測試手機下載安裝
<!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">
<title>Setup My App</title>
</head>
<body>
<a style="font-size:100px"href="itms-services://?action=download-manifest&url=https://dl.dropboxusercontent.com/s/hre0xxxxxxx/manifest.plist"> Tap Here to Install the Application</a>
</body>
</html>
將紅字改成自己的manifest.plist的url,然後將檔案儲存成AdHoc.html
然後再一次上傳到Dropbox,所以完成這些步驟之後dropbox一定會有三個檔案(ipa,plist,html)
最後再取得html的url傳給要安裝的測試者進行安裝
最後你的手機上面就會開始安裝APP囉!!
參考:http://kirkhsutw.blogspot.tw/2015/05/ios-ad-hoc.html