iOS Enterpriseプログラムで作成したMonoTouch AppをIISからOTA配信してみた
OTA配信するためには以下の物が必要になる。
- MonoTouchのライセンス
- Appを正式に署名できる証明書等
- デバイスがインターネットに接続できる環境(3GやWiFi等)
- 画像2種
- info.plistの設定
- plistファイル
- ipaファイル
- plistファイルへのリンクが書かれたHTMLファイル
- IISサーバー
MonoTouchのライセンス
そもそもライセンスが無ければデバイス用のバイナリをビルドできない。
Appを正式に署名できる証明書等
デバイス用のバイナリをビルドするために必要。iOS Dev Centerで発行する。
デバイスがインターネットに接続できる環境(3GやWiFi等)
AppをMonoDevelopからインストールしたときと違い、OTA経由でインストールした場合はApp起動時に証明書の有効性確認の為ocsp.apple.comにアクセスしようとする模様。よってインターネットへの接続環境が必要になる。
アイコン画像2種
一つはインストール中にホームに表示される57x57ピクセルのPNG画像。
一つはiTunesに表示される512x512ピクセルのPNG画像。
57x57の画像はAppにバンドルするアイコンを流用した。
512x512の画像はOTA配信では表示される所が無かったので大きさだけ合わせた白一色画像を用意した。
plistファイル
Appの情報やipaファイルへのリンクを記述したファイル。
以下のテンプレートを元に作成した。
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!-- array of downloads. -->
<key>items</key>
<array>
<dict>
<!-- an array of assets to download -->
<key>assets</key>
<array>
<!-- software-package: the ipa to install. -->
<dict>
<!-- required. the asset kind. -->
<key>kind</key>
<string>software-package</string>
<!-- required. the URL of the file to download. -->
<key>url</key>
<string>ipaファイルへのURL(フルパス)</string>
</dict>
<!-- display-image: the icon to display during download .-->
<dict>
<key>kind</key>
<string>display-image</string>
<!-- optional. indicates if icon needs shine effect applied. -->
<key>needs-shine</key>
<true/>
<key>url</key>
<string>57x57ピクセルpngファイルへのURL(フルパス)</string>
</dict>
<!-- full-size-image: the large 512x512 icon used by iTunes. -->
<dict>
<key>kind</key>
<string>full-size-image</string>
<key>needs-shine</key>
<true/>
<key>url</key>
<string>512x512ピクセルファイルへのURL(フルパス)</string>
</dict>
</array><key>metadata</key>
<dict>
<!-- required -->
<key>bundle-identifier</key>
<string>Appを識別するためのIdentifier文字列</string>
<!-- optional (software only) -->
<key>bundle-version</key>
<string>バージョン番号文字列</string>
<!-- required. the download kind. -->
<key>kind</key>
<string>software</string>
<!-- optional. displayed during download; typically company name -->
<key>subtitle</key>
<string>会社名</string>
<!-- required. the title to display during the download. -->
<key>title</key>
<string>App名</string>
</dict>
</dict>
</array>
</dict>
</plist>
今回は以下の様にした。ファイル名はtestapp.plist
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <!-- array of downloads. --> <key>items</key> <array> <dict> <!-- an array of assets to download --> <key>assets</key> <array> <!-- software-package: the ipa to install. --> <dict> <!-- required. the asset kind. --> <key>kind</key> <string>software-package</string> <!-- required. the URL of the file to download. --> <key>url</key> <string>http://myserver/testapp-1.0.ipa</string> </dict> <!-- display-image: the icon to display during download .--> <dict> <key>kind</key> <string>display-image</string> <!-- optional. indicates if icon needs shine effect applied. --> <key>needs-shine</key> <true/> <key>url</key> <string>http://myserver/testapp/image.57x57.png</string> </dict> <!-- full-size-image: the large 512x512 icon used by iTunes. --> <dict> <key>kind</key> <string>full-size-image</string> <key>needs-shine</key> <true/> <key>url</key> <string>http://myserver/testapp/image.512x512.png</string> </dict> </array><key>metadata</key> <dict> <!-- required --> <key>bundle-identifier</key> <string>com.myapp.testapp</string> <!-- optional (software only) --> <key>bundle-version</key> <string>1.0</string> <!-- required. the download kind. --> <key>kind</key> <string>software</string> <!-- optional. displayed during download; typically company name --> <key>subtitle</key> <string>マイカンパニー</string> <!-- required. the title to display during the download. --> <key>title</key> <string>テストApp</string> </dict> </dict> </array> </dict> </plist>
※bundle-identifierの部分にinfo.plistのIdentifierと同じ物を記述する
※bundle-versionの部分にinfo.plistのVersionと同じ物を記述する
※日本語を含む時はUTF-8エンコードで保存しなければならない。
※画像やipaファイルに対してMD5によるチェックサムを指定できる機能がある。今回は使わなかった。これは巨大なファイルに対してネットワーク転送時のエラーチェック機能になる。
ipaファイル
MonoDevelopからプロジェクト設定を変更するだけでビルド先に自動生成してくれる。
ファイル名は特に設定をしないとプロジェクト名+バージョン番号文字列+.ipaになる模様。
plistファイルへのリンクが書かれたHTMLファイル
Aタグのhref内を↓の用に記述する必要がある。
<a href="itms-services://?action=download-manifest&url=plistファイルへのフルパス">App名</a>
例えば以下の様になる。
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>OTA sample</title> </head> <body> <a href="itms-services://?action=download-manifest&url=http://myserver/testapp/testapp.plist">Test App</a> </body> </html>
今回はこのファイルをhttp://myserver/index.htmlとして作成した。
IISサーバー
通常のWEBサイトを作成する。そのWEBサイトに対してipaファイルとplistファイルのMIMEタイプを追加する
そしてipaファイル、plistファイル、png画像2種をWEBサイトに配置する。
これで準備が完了した。デバイスのSafariからhttp://myserver/index.htmlにアクセスして、リンクをクリックするとインストールが始まる。
インストール出来ないとき
"準備が出来ていない"と言われるとき。
- plistファイルへのリンクが書かれたHTMLファイルは正しいか?
- plist内の記述は正しいか?
インストールの最後の方で失敗する場合
- plist内のbundle-identifierとinfo.plistのIdentifierが同じになっているか?
- plist内のbundle-versionとinfo.plistのVersionと同じになっているか?
- Appは正しく署名されているか?
- そのAppはMonoDevelop経由でインストールして起動することが可能か?