LoginSignup
14
14

More than 5 years have passed since last update.

BITRISEでdebug版ipa配信/release版ipa配信(itunesConnectへの配信)/xctestを自動化

Last updated at Posted at 2018-02-20

OisixのiOSアプリ では、
* debug版ipa配信
* release版ipa配信(itunesConnectへの配信)
* XCTest
BITRISE で自動化しているのでやり方(bitrise.yml)を共有しようと思います。

bitrise.yml

※「〜」には必要な任意の文字列を入力

bitrise.yml
---
format_version: '4'
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
project_type: ios
trigger_map:
- push_branch: master
  workflow: dev-deploy
- pull_request_source_branch: "*"
  workflow: primary
- tag: "*"
  workflow: deploy
workflows:
  deploy:
    steps:
    - activate-ssh-key@3.1.1:
        run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
    - git-clone@4.0.5: {}
    - script@1.1.5:
        title: Do anything with Script step
    - certificate-and-profile-installer@1.9.2: {}
    - recreate-user-schemes@1.0.2:
        inputs:
        - project_path: "$BITRISE_PROJECT_PATH"
    - cocoapods-install@1.7.2: {}
    - xcode-archive@2.4.5:
        inputs:
        - project_path: "$BITRISE_PROJECT_PATH"
        - scheme: "$BITRISE_SCHEME"
        - upload_bitcode: 'no'
        - compile_bitcode: 'no'
        - configuration: Release
        - force_team_id: ''
        - force_code_sign_identity: iPhone Developer
        - export_method: app-store
    - deploy-to-itunesconnect-deliver@2.12.0:
        inputs:
        - password: 「iTunesConnectのパスワードを入力」
        - app_id: '「アプリのApp Idを入力」'
        - bundle_id:  「bundle_idを入力」
        - team_id: 「TEAM_IDを入力」
        - team_name: 「TEAM名を入力」
        - itunescon_user: 「iTunesConnectのユーザー名を入力」
    - slack@2.6.4:
        inputs:
        - channel: "#bitrise_ios"
        - message: |-
            *Submission :oisix: iOS App to iTunes Connect succeeded!* :tada:

            *App*
            $BITRISE_APP_TITLE ($BITRISE_APP_URL)
            *Build URL*
            $BITRISE_BUILD_URL
        - webhook_url: 「slackのwebhook URLを入力」
    envs:
    - BITRISE_EXPORT_METHOD: app-store
  primary:
    steps:
    - activate-ssh-key@3.1.1:
        run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
    - git-clone@4.0.5: {}
    - cache-pull@2.0.1: {}
    - script@1.1.5:
        title: Do anything with Script step
    - certificate-and-profile-installer@1.9.2: {}
    - recreate-user-schemes@1.0.2:
        inputs:
        - project_path: "$BITRISE_PROJECT_PATH"
    - cocoapods-install@1.7.2: {}
    - xcode-test@1.18.9:
        inputs:
        - project_path: "$BITRISE_PROJECT_PATH"
        - scheme: "$BITRISE_SCHEME"
    - deploy-to-bitrise-io@1.3.10: {}
    - cache-push@2.0.3: {}
    - slack@2.6.3:
        inputs:
        - channel: bitrise_ios
        - message_on_error: Ooops! Occured build failed. Please fix incorrect points.
        - message: Succeed build and xctest.
        - webhook_url: 「slackのwebhook URLを入力」
  dev-deploy:
    steps:
    - activate-ssh-key@3.1.1:
        run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
    - git-clone@4.0.5: {}
    - script@1.1.5:
        title: Do anything with Script step
    - certificate-and-profile-installer@1.9.2: {}
    - recreate-user-schemes@1.0.2:
        inputs:
        - project_path: "$BITRISE_PROJECT_PATH"
    - cocoapods-install@1.7.2: {}
    - xcode-archive@2.4.5:
        inputs:
        - project_path: "$BITRISE_PROJECT_PATH"
        - scheme: "$BITRISE_SCHEME"
        - upload_bitcode: 'no'
        - compile_bitcode: 'no'
        - configuration: Debug
        - force_code_sign_identity: iPhone Developer
        - is_export_xcarchive_zip: 'yes'
        - export_method: development
    - ipa-info@1.1.0: {}
    - deploy-to-bitrise-io@1.3.10:
        inputs:
        - notify_email_list:  「Debug版ipaの配信先メールアドレスを入力」
    - slack@2.6.4:
        inputs:
        - channel: "#bitrise_ios"
        - message: |-
            *Creation :oisix: iOS App for dev succeeded!* :tada:
            Let's submit to Apple.

            *App*
            $BITRISE_APP_TITLE ($BITRISE_APP_URL)
            *Build URL*
            $BITRISE_BUILD_URL
            *iTunes Connect URL*
            https://itunesconnect.apple.com
        - webhook_url: 「slackのwebhook URLを入力」
    envs:
    - BITRISE_EXPORT_METHOD: development
app:
  envs:
  - opts:
      is_expand: false
    BITRISE_PROJECT_PATH: 「アーカイブビルド対象のプロジェクトファイル名(〜.xcworkspace or 〜.xcodeproj)を入力」
  - opts:
      is_expand: false
    BITRISE_SCHEME: 「アーカイブビルド対象のScheme名を入力」
  - opts:
      is_expand: false
    BITRISE_EXPORT_METHOD: development

やっていること

トリガー

workflow(Bitriseで行う処理)実行のトリガーは下記の通り。

  • masterブランチへプッシュ時、workflow: dev-deploy(Debug版ipa配信)を実行。
  • pull request 時、workflow: primary(XCTestを実行)を実行
  • gitのタグをつけた時、workflow: deploy(itunesConnectへRelease版ipaを配信)を実行

workflow: dev-deploy(Debug版ipa配信)

処理概要

  • git clone
  • 証明書/プロファイルのインストール
  • cocoa pods install
  • Xcodeでarchive(Debug)
  • Debug版ipaをメール配信
  • Slackで通知

workflow: deploy(Release版ipa配信)

事前準備

  • iTunesConnectで対象アプリの新バージョンのページを作っておく。
  • 新しくiTunesConnectに申請する新バージョンでソース(info.plist)を更新しておく。この辺はBitriseでもバージョンインクリメントできそうだったがそれはやっていないです。

処理概要

  • git clone
  • 証明書/プロファイルのインストール
  • cocoa pods install
  • Xcodeでarchive(Release)
  • Relese版ipaをiTunesConnectへ配信
  • Slackで通知

workflow: primary(debugビルドとXCTest)

処理概要

  • git clone
  • 証明書/プロファイルのインストール
  • cocoa pods install
  • XcodeでXCTest実行
  • Relese版ipaをiTunesConnectへ配信
  • Slackで通知

Code Signing (Provisioning Profileと証明書)

  • ここがハマったのですが、ルートディレクトリで下記のコマンドを実行して出力されるProvisioning Profileと証明書(p12ファイル)をbitriseにアップする必要があります。ここにmember centerから手動落としたProvisioning Profileを混ぜるとビルドエラーになりました(下記コマンドから出力されるProvisioning Profileと証明書のみをBitriseにアップロードする必要がある)。
terminal
bash -l -c "$(curl -sfL https://raw.githubusercontent.com/bitrise-tools/codesigndoc/master/_scripts/install_wrap.sh)"
  • わたしの場合、bunbleIdはDebugビルドとReleaseビルドで別にしていたので、XcodeのbunbleId設定を変更(Xcode上ではproduct bundle indentifierでconfigurationsを別にしているがうまく認識しなかった)して2回上記コマンドをたたきProvisioning Profileと証明書(p12ファイル)をbitiriseへアップロードしました。

ハマりポイント

member centerから手動でProvisioning Profileと証明書を落としてきて、Bitriseにアップした場合(また、それが含まれていた場合)、ビルドエラー(Provisioning Profile関連)になりました。

この辺の設定方法は、詳しくは下記の通りで。わたしは下記のExporting manuallyはうまくいかなかったです。
https://ioscodesigning.com/exporting-code-signing-files/#exporting-with-codesigndoc

まとめ

  • Code Signing (Provisioning Profileと証明書)のところはハマりましたが、それ以外はグラフィカルにworkflowも作れてbitriseはとても使いやすいと思いました。
  • bitriseのstepのcontributersになるとproプラン利用者だったら月$25の割引を永遠に受けられるようです。
    https://discuss.bitrise.io/t/bitrise-contributors/167
14
14
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
14
14