Edited at

[iOS][fastlane][BITRISE] 構築メモ

iOSのビルド環境をfastlaneでBitriseに組んでみたメモ


やりたい事


  • 指定のブランチにpushされたら、ビルドしてfabricのBetaに配布

  • 環境毎に色々変える

  • なるべくfastlaneで


構成


  • XCode (9.3)

  • fastlane (2.105.2)

  • GitLab (self-host)

  • Bitrise



やった事


Bitrise

ほぼfastlane呼ぶだけ。Code SigningやSecrets、Env Varsなし


bitrise.yml

---

format_version: '5'
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
project_type: ios
workflows:
beta:
steps:
- activate-ssh-key:
run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
inputs:
- verbose: 'true'
- git-clone:
inputs:
- update_submodules: 'no'
- cache-pull: {}
- fastlane:
inputs:
- lane: beta
- cache-push:
inputs:
- cache_paths: "$BITRISE_CACHE_DIR"
trigger_map:
- push_branch: beta/*
workflow: beta



fastlane



  • import_from_gitでPrivate RepositoryのFastfileからENVに読み込む


fastlane/Fastfile

default_platform(:ios)

import_from_git(
url: "ssh://git@hoge/secret.git", branch: "master"
)

platform :ios do

lane :beta do |options|
if is_ci?
ENV["FASTLANE_PASSWORD"]=ENV["APPLE_ID_PASSWORD"]
end

match

update_build_number
add_badge(dark: true)

build(
app_identifier: ENV["APP_IDENTIFIER_BETA"],
provisioning_profile: ENV["PROVISIONING_PROFILE_BETA"],
development_team: ENV["TEAM_ID"]
)

if is_ci?
add_git_tag
push_git_tags
end

crashlytics
upload_symbols_to_crashlytics

end
end




  • increment_build_numberが使いにくかったのでupdate_build_numberを作った

  private_lane :update_build_number do

app_version = get_info_plist_value(path:'./Info.plist', key: 'CFBundleShortVersionString')
next_build_number = "#{app_version}.#{number_of_commits}"
set_info_plist_value(path: './Info.plist', key: 'CFBundleVersion', value: next_build_number)
lane_context[SharedValues::BUILD_NUMBER] = next_build_number
end


  • Xcode9とmatchでgymがうまくいかなった分の対応


    • Exit status: 65とかExit status: 70とか




Fastlane gym does not use provisioning profile set by match


  private_lane :build do |options|

settings_to_override = {
:BUNDLE_IDENTIFIER => options[:app_identifier],
:PROVISIONING_PROFILE_SPECIFIER => options[:provisioning_profile],
:DEVELOPMENT_TEAM => options[:development_team]
}
gym(xcargs: settings_to_override)
end


設定はそれぞれに


fastlane/Appfile

apple_id ENV["APPLE_ID"]

team_id ENV["TEAM_ID"]


fastlane/Matchfile

git_url "ssh://git@hoge/certificates.git"

for_lane :beta do
force_for_new_devices true
type "adhoc"
end


fastlane/Gymfile

for_lane :beta do

scheme "Beta"
export_method "ad-hoc"
end


やりたい事


  • deliverでrelease

  • slackからbeta, release

  • danger