つばくろぐ @takamii228

知は力なり

WindowsからApp Store Connectにipaファイルをアップロードする

ipaファイルをApp Store Connectへアップロードする場合、Xcode上でAcrhive後にそのままアップロードする方法と、macOSアプリとして配布されているTransporter というアップローダーツールを使う方法があります。

Transporter

Transporter

apps.apple.com

このTransporterについて詳しく調べていたら、どうやらjavaベースのCLIツールもあってしかもLinuxWindows向けも用意されていることが判明しました。

help.apple.com

What is Transporter?
Transporter is Apple’s Java-based command-line tool for large catalog deliveries. You can use Transporter to deliver your pre-generated content, in a Store Package, to the iTunes Store, Apple Books, and App Store.
...
(中略)
Transporter includes the following features:

An easy-to-use, out-of-the-box installation package, including installers for macOS, Microsoft’s Windows, and Red Hat Enterprise Linux.
...

iTunes StoreApple Booksとあるのでメディア・コンテンツのアップロードツールっぽいですが、App Storeへのアップロードもサポートしているようです。

iOSアプリの開発にはmacOSは必須ですし、App Store Connectへのアップロードには当然macOSが必要だと思ってたらWindowsでもLinuxでもアップロードできるんですね。

ということで今回はこのTransporterのCLIツールを使ってWindowsipaファイルをアップロードする方法をまとめてみます。

TransporterをWindows上でインストールする

マニュアルの Install Transporter on Windowsに従ってexeをダウンロードして、実行するとダウンロードコマンド一式が落ちてきます。

'C:\Program Files (x86)\itms というところに iTMSTransporter.cmd があるので、これをPowerShell上で実行すればよさそうです。

PS C:\Users\xxxxxx> & 'C:\Program Files (x86)\itms\iTMSTransporter.cmd' -help
[2020-12-26 13:32:18 JST] <main>  INFO: Configuring logging...
[2020-12-26 13:32:18 JST] <main>  INFO: Logging level set to eXtreme
[2020-12-26 13:32:18 JST] <main>  INFO: Transporter is searching for new software components.
[2020-12-26 13:32:18 JST] <main>  INFO: INFO: using cached repository.xml file.
[2020-12-26 13:32:19 JST] <main>  INFO: Update check complete.
[2020-12-26 13:32:21 JST] <main> DEBUG: Attempting refresh of configuration data from https://contentdelivery.itunes.apple.com/transporter/Defaults.properties
[2020-12-26 13:32:21 JST] <main> DEBUG: Configuration refresh successful.
[2020-12-26 13:32:21 JST] <main> DEBUG: Saving configuration to local path: C:\Users\xxxxxi\.itmstransporter\Defaults.properties
usage: iTMSTransporter [-help <arg> | -info | -m <arg> | -version]   [-o <arg>] [-v
       <arg>]  [-WONoPause <arg>] [-Xmx4096m]
iTMSTransporter : iTunes Store Transporter 2.1.0
 -help <arg>        Show this help.  If a mode value is specified, show help specific
                    to that mode.
 -info              The -info option should be used by itself and returns the
                    copyright notice and acknowledgements.
 -m <arg>           The -m option specifies the tool's mode.  The valid values are:
                    verify, upload, provider, diagnostic, lookupMetadata,
                    createArtist, lookupArtist, status, statusAll,
                    createMetadataTicket, queryTickets, generateSchema, transferTest,
                    downloadMetadataGuides, listReports, requestReport
 -o <arg>           The -o option specifies the directory and filename you want to use
                    to log output information.  By default, Transporter logs output
                    information to standard out. If you specify a filename,
                    Transporter logs the output to the specified file, as well as to
                    standard out.
 -v <arg>           The -v option specifies the level of logging.  The five values
                    are: off, detailed, informational, critical, eXtreme.
 -version           The -version option should be used by itself and returns the
                    version of the tool.
 -WONoPause <arg>   The -WONoPause option is only valid on Windows and its value can
                    be 'true' or 'false'.  If an error occurs during script execution,
                    the process idles because the message 'Press any key...' is
                    displayed on the console and the system awaits a keypress. To
                    avoid this behavior, set this property to true
 -Xmx4096m          Specifies that you want to change the Java Virtual Machine's (JVM)
                    allocated memory by increasing the JVM heap size.  By default,
                    Transporter uses a 2048MB heap size. You can use the -Xmx4096m
                    option to specify a 4-gigabyte (GB) heap size. Apple recommends,
                    if needed, increasing the heap size to 4096MB by specifying the
                    -Xmx4096m (or -Xmx4g) option and adjusting as needed.
[2020-12-26 13:32:21 JST] <main> DBG-X: Returning 0

今回はApp Store Connectへのアップロードなのでmodeとしてはuploadを使えばよさそうです。

-u-pオプションでApp Store Connectへのクレデンシャル情報を設定するようです。

アップロードするipaファイルパスの指定は -assetFile オプションを使うようで、さらにLinuxWindowsの場合は-assetDescriptionオプションをつけろと書いてあります。

App uploads for macOS, Linux, and Windows: Specifies the directory and filename for the app source file (.pkg or .ipa). For Linux and Windows, -assetDescription is required.

なんじゃこのファイルと思ったらArchiveをExportするときに生成するファイルのようで、ExportOption.plistファイルに指定しておけばよさそうです。

https://help.apple.com/xcode/mac/current/#/deva1f2ab5a2

ipaファイルを作成する

適当なサンプルアプリをmacOS上で作ってipaファイルを配布用の証明書で署名し、Exportします。

ExportOption.plistファイルに以下のようにgenerateAppStoreInformationをセットするとAppStoreInfo.plistというファイルが生成されました。

<dict>
        ...
    <key>generateAppStoreInformation</key>
    <true/>
</dict>

設定の詳細はこちら。

qiita.com

生成したipaファイルとAppStoreInfo.plistファイルをWindowsに持っていきます。

Windows上でTransporterのコマンドを実行してみる

いよいよWindows上でTransporterコマンドを実行してみます。

PS C:\Users\xxxxxx> & 'C:\Program Files (x86)\itms\iTMSTransporter.cmd' -m upload -assetFile .\Desktop\sample.ipa -u xxxxx
  -p xxxxxx -assetDescription .\Desktop\AppStoreInfo.plist -v eXtreme

実行してみると、アップロード処理に失敗して以下のようなエラーが発生しました。

[2020-12-26 13:46:24 JST] <main> ERROR: Sign in with the app-specific password you generated. If you forgot the app-specific password or need to create a new one, go to appleid.apple.com (-22938)

どうやらここで指定するパスワードはApple IDのパスワードではなくてapp-specific passwordというのを指定するようです。

Transporterのドキュメントにも書いてありました。二段階認証を設定しているアカウント向けのアクセストークン相当のもののようです。

Two-factor authentication

If you have enabled two-factor authentication on your account, you must create an app-specific password, as described in Using app-specific passwords. Using an app-specific password increases the level of security and ensures your Apple ID password won’t be collected or stored by third-party apps.

発行方法はこちらに書いてありました。

support.apple.com

Apple IDの設定画面でapp-specific passwordを生成し、設定して再度実行すると無事アップロードが成功しました。

PS C:\Users\xxxxxx> & 'C:\Program Files (x86)\itms\iTMSTransporter.cmd' -m upload -assetFile .\Desktop\sample.ipa -u xxxxx
  -p xxxxxx -assetDescription .\Desktop\AppStoreInfo.plist -v eXtreme

今回は試しませんが、おそらく似たようなやり方でLinuxからもアップロードできるでしょう。

まとめ

WindowsでもTransporterのコマンドラインツールを使えばApp Store Connectへアップロードできることがわかりました。

政治的にmacOSが使えなかったり購入できなくて「どうしてもWindowsでできないのか」と聞かれた時にはぜひこのやり方を紹介するとよいでしょう。

個人的にはXcodeやTransporter使った方が楽なので、macOSのマシンを1台購入することをおすすめします。