LoginSignup
115
112

More than 5 years have passed since last update.

Xcode プロジェクトから ipa を作成する方法

Last updated at Posted at 2015-06-20

Xcode プロジェクトをビルドして、ipa を作成する方法はいくつかある。

Xcode から作成する方法

  1. Archive を作成する (Xcode のメニュー Product -> Archive をする)
  2. Organizer が開く
  3. Export -> Save for Ad Hoc Deployment
    • Screen Shot 2015-06-20 at 10.58.32 PM.png

コマンドで作成する方法

Xcode 8.3以上の場合

Xcode 8.3以上の場合は、 -exportOptionsPlist オプションで設定ファイル( .plist ) を指定します。

ストアに提出しないが、とにかく ipa を作りたい場合は以下のような plist を作成し、コマンド実行することで ipa ファイルを作成できる。

export_ipa_sample.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>method</key>
    <string>ad-hoc</string>
</dict>
</plist>
$ xcodebuild -exportArchive -archivePath /Users/sea_mountain/Library/Developer/Xcode/Archives/2015-06-20/Unity-iPhone\ 6-20-15,\ 4.18\ PM.xcarchive -exportPath ipa_dir -exportOptionsPlist export_ipa_sample.plist

(ここでexportに失敗する場合は、エラーメッセージを見つつ、有効な証明書がPCにインストールされているか等を確認する。)

ストアに提出する等、細かい設定が必要な場合は、以下を参考に plist を作成する。

具体的な設定項目は以下 ( xcodebuild -help コマンドより抜粋)

日本語の分かりやすい記事はこちら xcodebuildでipa作成 -exportOptionsPlist対応版

    compileBitcode : Bool

        For non-App Store exports, should Xcode re-compile the app from bitcode? Defaults to YES.

    embedOnDemandResourcesAssetPacksInBundle : Bool

        For non-App Store exports, if the app uses On Demand Resources and this is YES, asset packs are embedded in the app bundle so that the app can be tested without a server to host asset packs. Defaults to YES unless onDemandResourcesAssetPacksBaseURL is specified.

    iCloudContainerEnvironment

        For non-App Store exports, if the app is using CloudKit, this configures the "com.apple.developer.icloud-container-environment" entitlement. Available options: Development and Production. Defaults to Development.

    manifest : Dictionary

        For non-App Store exports, users can download your app over the web by opening your distribution manifest file in a web browser. To generate a distribution manifest, the value of this key should be a dictionary with three sub-keys: appURL, displayImageURL, fullSizeImageURL. The additional sub-key assetPackManifestURL is required when using on demand resources.

    method : String

        Describes how Xcode should export the archive. Available options: app-store, ad-hoc, package, enterprise, development, and developer-id. The list of options varies based on the type of archive. Defaults to development.

    onDemandResourcesAssetPacksBaseURL : String

        For non-App Store exports, if the app uses On Demand Resources and embedOnDemandResourcesAssetPacksInBundle isn't YES, this should be a base URL specifying where asset packs are going to be hosted. This configures the app to download asset packs from the specified URL.

    teamID : String

        The Developer Portal team to use for this export. Defaults to the team used to build the archive.

    thinning : String

        For non-App Store exports, should Xcode thin the package for one or more device variants? Available options: <none> (Xcode produces a non-thinned universal app), <thin-for-all-variants> (Xcode produces a universal app and all available thinned variants), or a model identifier for a specific device (e.g. "iPhone7,1"). Defaults to <none>.

    uploadBitcode : Bool

        For App Store exports, should the package include bitcode? Defaults to YES.

    uploadSymbols : Bool

        For App Store exports, should the package include symbols? Defaults to YES.

上記の項目をすべて記載すると以下の様な記述になりそう。
(あくまで項目数のイメージのため。値を設定していないプロパティがあるのと、動作確認はしていないため、コピペ用または参考程度まで)

sample.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>compileBitcode</key>
    <true/>
    <key>embedOnDemandResourcesAssetPacksInBundle</key>
    <true/>
    <key>iCloudContainerEnvironment</key>
    <string>Development</string>
    <key>manifest</key>
    <dict>
        <key>appURL</key>
        <string></string>
        <key>displayImageURL</key>
        <string></string>
        <key>fullSizeImageURL</key>
        <string></string>
        <key>assetPackManifestURL</key>
        <string></string>
    </dict>
    <key>method</key>
    <string>development</string>
    <key>onDemandResourcesAssetPacksBaseURL</key>
    <string></string>
    <key>teamID</key>
    <string></string>
    <key>thinning</key>
    <string></string>
    <key>uploadBitcode</key>
    <true/>
    <key>uploadSymbols</key>
    <true/>
</dict>
</plist>

Xcode 8.3未満の場合

Xcode 8.3より以下で記載するコマンドオプションが使用できなくなっています。

Xcode 8.3 Deprecation and Removal Notices

The -exportFormat parameter of the -exportArchive option for xcodebuild has been removed. To set the export format, use the -exportOptionsPlist parameter to specify an export plist file with the method key set to the desired format. For more information on the keys and values for the export plist, run xcodebuild -help on the command line.


Archive を作成する手順は、上記 Xcode から作成する場合と同様で、Xcode のメニュー Product -> Archive。

  • Archive 終了後、以下のコマンドで作成する

    xcodebuild -exportArchive -archivePath #{xcarchiveのパス} -exportProvisioningProfile #{Provisioning Profile名} -exportPath #{ipaの出力パス} -exportFormat ipa
    
  • オプション説明

    • archivePath
      • Archive で作成された .xcarchive のパスを指定する
      • xcarchive のパスを知りたいとき
        • Organizer の Archive のリストの上で右クリック -> "Show in Finder" でそのパスを Finder で開く事ができる
    • exportProvisioningProfile
      • ProvisioningProfile の指定
      • ※注意 ここで指定するのは Apple Developer の Member Center で表示されている、ProvisioningProfile 名
        • Screen Shot 2015-06-20 at 11.47.19 PM.png
    • exportPath
      • ipa の出力先
    • exportFormat
      • フォーマットの指定
        • ipa か pkg を指定できる。今回は ipa
  • 実行コマンド例

    $ xcodebuild -exportArchive -archivePath /Users/sea_mountain/Library/Developer/Xcode/Archives/2015-06-20/Unity-iPhone\ 6-20-15,\ 4.18\ PM.xcarchive -exportProvisioningProfile "XC: com.SeaMountain.UnityChan" -exportPath ./build/2015-06-20_mono.ipa
    
115
112
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
115
112