[iOS] Fastlane으로 배포 자동화하기

someng·2022년 10월 31일
0

iOS

목록 보기
17/33

1. Fastlane 설치 (Bundler 이용)

Bundler

Bundler 와 Gemfile 을 이용해서 fastlane 의존성 관리하기

1-1. 터미널에서 gem install bundler 입력해서 번들러 설치


만약, 에러가 발생했다면 아래 절차를 따른다.

  • brew update

  • brew install rbenv ruby-build

  • rbenv versions : rbenv 가 잘 설치되었는지 확인

  • rbenv install -l : 설치 가능한 Ruby 버전 확인

  • rbenv install 3.1.2 : 최신 버전(2022.10.31 기준) 설치

  • rbenv versions

  • rbenv global 3.1.2 글로벌 버전을 3.1.2로 변경

  • 본인의 쉘 설정 파일 (.zshrc, .bashrc) 을 열어 다음의 코드를 추가
    vim ~/.zshrc

    [[ -d ~/.rbenv  ]] && \
      export PATH=${HOME}/.rbenv/bin:${PATH} && \
      eval "$(rbenv init -)"

    source ~/.zshrc : 코드 적용
    이제 다시 gem install bundler 을 실행해본다.

    bundler 설치 성공! ✨

1-2. 프로젝트 폴더에서 ./Gemfile 파일에 내용 추가

  • vim ./Gemfile

    source "https://rubygems.org"
    
    gem "fastlane"
  • bundle update

  • 버전 컨트롤에 ./Gemfile ./Gemfile.lock 파일 추가

  • CI나 처음 fastlane을 돌리는 경우, bundle install 실행

2. Fastlane 설정

2-1. 프로젝트 폴더에서 fastlane init 돌리기

  • fastlane 실행 명령어: bundle exec fastlane [lane]

    fastlane 사용 목적 선택: 앱 배포 목적이니까 3번 선택 ✅

  • 애플 로그인, 비번, 이중인증

  • 메타데이터 관리를 fastlane 을 이용할것이냐? 질문에 y 입력!

  • 가이드 라인과 함께 완료! 👍🏻

  • 프로젝트 폴더에 새로운 파일이 추가된 것을 확인할 수 있다!

2-2. Fastfile 에 Lane 추가
나는 현재 베타 버전 출시를 사용하지 않고 있기 때문에 기존 파일에서
upload_to_app_store 괄호 부분만 추가했다.

# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
#     https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out
#
#     https://docs.fastlane.tools/plugins/available-plugins
#

# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane

default_platform(:ios)

platform :ios do
  desc "Push a new release build to the App Store"
  lane :release do
    increment_build_number(xcodeproj: "Dr.Gourmet.swiftUI.xcodeproj")
    build_app(workspace: "Dr.Gourmet.swiftUI.xcworkspace", scheme: "Dr.Gourmet.swiftUI")
    upload_to_app_store(
      force: true, # Skip HTMl report verification
      skip_metadata: true,
      skip_screenshots: true,
    )
  end
end

3. 배포하기

  • 프로젝트 폴더에서 bundle exec fastlane ios release 실행

    잘 실행되는듯 싶더니.. 두둥 에러 발견!

    구글링을 해보니 https://appleid.apple.com/account/manage 에 들어가 App-Specific Passwords 를 생성하고,
    fastlane 폴더에 .env.default라는 새로운 파일을 만들어 아래 내용을 추가하면 된다고 한다.
FASTLANE_USER=<Apple USER ID>
FASTLANE_PASSWORD=<App-Specific Password>
  • 위 절차대로 수행한 후에,
    다시 bundle exec fastlane ios release 실행하니 배포가 성공적으로 완료되었다!! 🥳
profile
👩🏻‍💻 iOS Developer

0개의 댓글