andrei
andrei

Reputation: 2083

Increment build number with fastlane without changing project file?

I am setting up fastlane to run the builds of our iOS app. Is there a way to increment the build number based on the latest TestFlight build and upload a build, but without changing the project file? I'd rather not pollute the Git history with build number changes. Currently the app is being built with Xcode Cloud and somehow it's managing to keep CURRENT_PROJECT_VERSION = 1 in the project file.

Unless I'm missing something I would basically have to do:

    current_version = get_version_number()
    previous_build_number = latest_testflight_build_number(
      api_key: api_key,
      app_identifier: app_identifier,
      version: current_version
    )
    
    current_build_number = previous_build_number + 1
    
    increment_build_number(
      build_number: current_build_number
    )
    
    build_ios_app(...)
    
    increment_build_number(
      build_number: 1
    )

Upvotes: 0

Views: 3301

Answers (1)

Avinash Jadhav
Avinash Jadhav

Reputation: 501

Check if following fastlanes code helps for you

  1. get yourself authenticated with Apple Store

    lane :authenticate_app_store do
      app_store_connect_api_key(
             key_id: ENV['KEY_ID'],
             issuer_id: ENV['ISSUER_ID'],
             key_content: ENV['KEY_CONTENT'],
             is_key_content_base64: true,
             in_house: false
      )
    end
    
  2. Update your build number

     lane :set_build_number do 
           authenticate_app_store
           increment_version_number(version_number: ENV['APP_VERSION'])
           increment_build_number({ build_number: latest_testflight_build_number(version: ENV['APP_VERSION'], app_identifier: 'com.retaininternational.phoenixmobile') + 1 })
     end
    

Check for complete fastlane setup

Upvotes: 0

Related Questions