Swift・iOS

Swiftを中心に学んだことを記録に残すブログです。技術に関係ない記事もたまに書いています。

【Bitrise】App Store Connectにアプリをアップロードする

 

はじめに

Bitriseのドキュメントが充実しているのは初心者にとってとてもありがたいのですが、「ここはもう少し細かく説明してほしい・・・」、「この設定ってどこからやればいいんだろう・・・?」と感じることがたびたびありました。

この記事では、BitriseでApp Store Connectにアプリをアップロードする手順に関して、以下のドキュメントだけでは理解できない方向けに、手順をより細かめに説明してみました。

iOSアプリの開始 | Bitrise DevCenter

 

手順

開発者証明書を発行

Apple Developer > "Certificates, Identifiers & Profiles" > "Certificates"と遷移して、"iOS Distribution (App Store and Ad Hoc)"の証明書を発行。

発行後は証明書ファイルをダウンロードし、ダウンロードしたファイルをダブルクリックしてキーチェーンに登録。

f:id:hfoasi8fje3:20201115144936p:plain

 

"Identifiers"を登録

"Certificates, Identifiers & Profiles" > "Identifiers"と遷移して、"App IDs"を登録。

f:id:hfoasi8fje3:20201115151812p:plain

 

プロビジョニングプロファイルを発行

"Certificates, Identifiers & Profiles" > "Profiles"と遷移して、"App Store"用のプロビジョニングプロファイルを発行。

発行後はプロビジョニングプロファイルをダウンロードし、ダウンロードしたファイルをダブルクリック。

f:id:hfoasi8fje3:20201115145559p:plain

 

Xcodeの"PROJECT" > "Signing & Capabilities"で発行したプロビジョニングプロファイルを指定。指定時にエラーが出る場合は、証明書の発行に問題があるため必ずエラーを解消すること。

f:id:hfoasi8fje3:20201115150853p:plain

 

"the codesigndoc tool"を使ってBitriseに証明書をアップロード

※参考:Collecting and exporting code signing files with codesigndoc | Bitrise DevCenter

 

ターミナルを開いてプロジェクトの階層(.xcodeprojファイルがある階層)に移動して、以下コマンドを実行。

bash -l -c "$(curl -sfL https://raw.githubusercontent.com/bitrise-io/codesigndoc/master/_scripts/install_wrap-xcode.sh)"

 

以下が表示された場合は"app-store"を示す"2"を入力してEnter。

App was signed with NON xcode managed profile when archiving,
only NOT xcode managed profiles are allowed to sign when exporting the archive.
Removing xcode managed CodeSignInfo groups
Select the ipa export method
Please select from the list:
[1] : development
[2] : app-store
[3] : ad-hoc
[4] : enterprise
(type in the option's number, then hit Enter) [1] : 2

 

リリース用の開発者証明書とプロビジョニングプロファイルが指定されていることを、以下の表示内容で確認。

Codesign settings will be used for app-store .ipa/.app export:
development team: ~
codesign identity: iPhone Distribution: ~
provisioning profiles: ~

 

リリース用の開発者証明書とプロビジョニングプロファイルが指定されていれば、以下で"NO"と入力してEnter。

Do you want to collect another ipa export code sign files
(select NO to finish collecting codesign files and continue) [yes/NO]: NO

 

以下で"yes"と入力してEnter。

Do you want to upload the provisioning profiles and certificates to Bitrise? [yes/no] : yes

 

Bitriseのアクセストークンを入力してEnter。

Please copy your personal access token to Bitrise.
(To acquire a Personal Access Token for your user, sign in with that user on bitrise.io, go to your Account Settings page,
and select the Security tab on the left side.) : 

 

以下が表示されればアップロード完了。

Exports finished you can find the exported files at: ~
Opened the directory in Finder.

That's all.

 

※Bitriseのアクセストークンに関して

Bitriseの右上にあるアイコン > "Account settings"を選択。

f:id:hfoasi8fje3:20201115162751p:plain

 

画面左下にある"Security"を選択。

f:id:hfoasi8fje3:20201115163044p:plain

 

"Generate new"を選択。

"Token description"に任意の文字を入力して"Save & Continue"を選択すると、アクセストークンが発行される。

f:id:hfoasi8fje3:20201115163343p:plain

 

Bitriseにアプリを追加

以下のドキュメントの手順にしたがってアプリを追加。

iOSアプリの開始 | Bitrise DevCenter

※追加する過程で、スキームに関する警告が発生した場合は、以下の記事を参照。

www.hfoasi8fje3.work

 

ワークフローを追加

ダッシュボードの画面で、手順5で追加したアプリを選択。

f:id:hfoasi8fje3:20201115190157p:plain

 

"Workflow"を選択。

f:id:hfoasi8fje3:20201115190425p:plain

 

"+ Workflow"を選択。

f:id:hfoasi8fje3:20201115190743p:plain

 

"Workflow name"に任意の文字を入力して、"BASED ON"は"deploy"にして"Done"を選択。

f:id:hfoasi8fje3:20201115190926p:plain

 

ステップの設定を変更

追加したワークフローの"Xcode Archive & Export for iOS"ステップの"Select method for export"を"app-store"に変更。

f:id:hfoasi8fje3:20201115192226p:plain

 

ワークフローにステップを追加

"Deploy to iTunes Connect - Application Loader"ステップを、"Xcode Archive & Export for iOS"と"Deploy to Bitrise.io"の間に追加。

f:id:hfoasi8fje3:20201115194150p:plain

 

"Deploy to iTunes Connect - Application Loader"ステップを設定

"Deploy to iTunes Connect - Application Loader"ステップを選択後、"Apple ID"にある"Select secret variable"を選択。

f:id:hfoasi8fje3:20201115213221p:plain

 

"Key"に任意の文字(Apple IDであることがわかる文字など)を入力し、"Value"にApple IDを入力して"Add new"を選択。登録したKeyを"Apple ID"欄に指定。

f:id:hfoasi8fje3:20201115213615p:plain

 

"Apple ID"を指定する手順と同じように、"Password"欄と"Application Specific Password"欄に値を指定する。具体的には、Apple IDのパスワードとアプリケーションのパスワードをsecret variableに登録する。その後、登録したApple IDのパスワードを表すKeyを"Password"に、登録したアプリケーションのパスワードを表すKeyを"Application Specific Password"に指定する。

f:id:hfoasi8fje3:20201115214404p:plain

※アプリケーションのパスワードを取得する方法

Manage your Apple IDにログインし、パスワードを生成を選択

f:id:hfoasi8fje3:20201115215754p:plain

 

パスワードのラベル(任意の文字)を入力して「作成」を選択すると、アプリケーションのパスワードが発行される。

f:id:hfoasi8fje3:20201115215935p:plain

 

ビルド実行

"Start/Schedule a build"を選択。

f:id:hfoasi8fje3:20201115220748p:plain

 

"Workflow"で、今回追加したワークフローを選択して、ビルドを実行。

f:id:hfoasi8fje3:20201115221018p:plain

 

ビルドが成功したらApp Store Connectを確認

https://appstoreconnect.apple.com/loginにログインして、「マイApp」にアプリが登録されていれば成功!

※"xcode-test@2 (exit code: 1)"や"Xcode Test command failed, error: exit status 70"でビルドが失敗する時は以下の記事を参照。

www.hfoasi8fje3.work

※注意点

・アップロードが失敗するため、"Assets.xcassets"にアプリアイコンとApp Store用アイコンを設定した上でビルドを実行すること。

 

おわりに

まだまだ細かく(丁寧に)手順を説明することはできますが、記事が長くなりすぎてしまうので、今回はドキュメントが端折っている部分を中心に細かく説明してみました。まとめてみると、改めてドキュメントの説明は結構端折られているように感じました。(もちろんそう感じるのは初心者だからですが。。)

App Store Connectにアプリをアップロードする手順以外にも、Bitriseで試したことや詰まったことは今後も記事に残していこうと思います。

 

参考

iOSアプリの開始 | Bitrise DevCenter

Collecting and exporting code signing files with codesigndoc | Bitrise DevCenter