본문 바로가기

Programming/iOS

[Fastlane] increment_build_number Action

반응형

배포를 하거나 CI에서 빌드할 때 Fastlane을 많이 사용하고 있다.

beta에 여러 번 업로드할 경우 builder number 가 같다고 오류가 발생한 경우를 모두 경험해 보셨을 것이다.

Fastlane 에는 이런 문제를 해결하기 위한 Action 이 있다.

 

increment_build_number

 

fastlane lane 을 실행하고 이 Action 이 실행되면 build number를 +1 하는 과정을 실행한다.

이것만 추가하면 build number 에 대한 걱정은 하지 않아도 된다.

 

그럼 추가해보자.

Fastlane 답게 추가는 간단하다. 아래 Fastfile 내용을 보시면 lane 아래에 추가만 하면 된다.

platform :ios do
  desc "Push a new beta build to TestFlight"
  lane :beta do
    increment_build_number
    build_app(scheme: "XXXXX")
    upload_to_testflight
  end
end

이후 실행해 보면 다음과 같은 오류를 만날 가능성이 크다.

[01:24:51]: Apple Generic Versioning is not enabled in this project.

Before being able to increment and read the version number from your Xcode project, you first need to setup your project properly. Please follow the guide at https://developer.apple.com/library/content/qa/qa1827/_index.html

오류 내용을 보면 Apple Generic Versioning 이 활성화 안 되어 있다고 한다.

이것을 활성화 하려면 어떻게 해야 할까?

마지막에 있는 링크를 클릭해 보면 해결 방법이 나온다.

 

내용이 많은데 다 볼 필요까지는 없다.

우리가 원하는건 build number 가 1씩 증가되기만을 원한다.

 

Build Settings 에서 2가지만 설정하면 된다.

 

Current Project Version

  • 현재 Build number 를 입력하자

Versioning System

  • Apple Generic 을 선택하자 (다른 건 없다..)

Xcode Build Settings Versioning

이제 다시 fastlane 을 실행해보자

bundle exec fastlane beta 

오 성공적으로 넘어 갔다.

현재 version 이 4라고 표시되고 오류 없이 넘어간다.

Fastlane increment_build_number Action

이제 정말 +1 이 되었는지 확인해 보자.

Info.plist 에서 Bundle version 이 +1 되어 5가 된 것을 확인할 수 있다.

Xcode Info.plist

Target의 Build Settings에서 확인해 봐도 5로 되어 있다.

Xcode Build Settings

성공적으로 increment_build_number을 적용했다!

반응형