LoginSignup
0
1

More than 1 year has passed since last update.

On Demand Resourceをテストする

Posted at

On Demand Resourceをテストする

  • ライブラリーをODRでダウンロードして使えるかをテスト

設定方法

  • XcodeのProject SettingのBuild Settingsに移動し、Enable On Demand Resourcesを Yesにする。
  • XcodeのProject SettingのResource Tagsタブに移動しタグを追加する。そのタグにODRにしたいAssetを追加する。

実装方法

Task {
    // NSBundleResourceRequestインスタスを先作成したタグ名で生成する
    let request = NSBundleResourceRequest(tags: Set(["Tag"]))
    // ODRがすでにダウンロードされたかを確認する
    let accessible = await request.conditionallyBeginAccessingResources()
    // ダウンロードされなかった場合、App Storeからダウンロードする
    do {
        try await request.beginAccessingResources()
    } catch {}
    // ダウンロードされている場合、すぐに使用可能
    request.bundle
}

テスト方法

  • 前準備:Ditribution認証書が必要。 ちゃんとした認証書(オレオレX)を使っているTLS(https)サーバーが必要。 AWS S3を使うと便利。
  1. XcodeでArchiveを実行した後OrganizerでDistribution Appボタンを押す1_step1.png
    2.Ad hocを選択する2_step2.png
    3.On-Demand ResourceをHost on Serverに変更する3_step3.png
    4.URLを入力する. App URLはAsset Pack Manifest URLは入力必須.4_step4.png
    5.生成されたファイルを全部サーバーにあげる 5_step5.png
    6.iPhoneから接続するhtmlを作って一緒にあげる
<html>
<a href="itms-services://?action=download-manifest&url=https://bluerain-blog.s3.ap-northeast-1.amazonaws.com/manifest.plist">App Install</a>
</html>
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1