글 작성자: HEROHJK

fastlane은 루비로 개발하였습니다.

 

fastfile에서 루비 언어를 이용하여 커스텀할 수 있습니다.

 

저는 fastlane에 testflight 업로드 스크립트를 만들어 두었는데요,

 

아래 함수를 조금 더 추가하여 날짜+카운팅 방식으로 변경하였습니다.

(2021051701, 2021051702, 2021051703 ... 2021051799)

 

default_platform(:ios)

platform :ios do
  desc "Push a new beta build to TestFlight"
  lane :beta do
    increment_build_number(xcodeproj: "Project.xcodeproj", build_number: date_based_build_number)
    build_app(scheme: "SchemeName")
    upload_to_testflight
  end
end


def today_formatted
  Date.today.strftime('%Y%m%d')
end


def default_build_number
  "#{today_formatted}01"
end


def date_based_build_number
  current_build_number = get_build_number(xcodeproj: "Project.xcodeproj")
  
  build_date = current_build_number[0..7]
  build_version = current_build_number[8..9]

  if (!build_date || !build_version) || (build_date.empty? || build_version.empty?)
    return default_build_number
  end

  begin
    build_date_object = Date.strptime(build_date, '%Y%m%d')
  rescue
    return default_build_number
  end


  if build_date_object >= Date.today
    new_version = build_version.to_i + 1
    return "#{today_formatted}%02d" % new_version
  end

  return default_build_number
end

 

반응형