2

I had setup fast lane and everything works fine and the app gets uploaded to test flight using the following fast file. I want to auto increment the build number based on the previous build number in TestFlight and upload new build with that incremented build number. Please advice how to do this

class Fastfile: LaneFile {

func customLane() {

    let buildNumber = latestTestflightBuildNumber(appIdentifier: "com.softence.DemoApp", username: "iosapp@dreamapps.com")
    incrementBuildNumber(buildNumber: String(describing: buildNumber + 1))

    buildIosApp(scheme: "DemoApp")
    uploadToTestflight(username: "iosapp@dreamapps.com", teamId: "39941891")
   }
}

After execution it again asks to select the team from list of teams. I want to increment the build number and upload the build directly to test flight

Mohanraj
  • 587
  • 4
  • 21

2 Answers2

1

On fastlane (2.205.2), this worked for me to get and set the last build from Testflight:

current_build_number = app_store_build_number(live: false) //live false means Testflight, true would take the current production build
increment_build_number(xcodeproj: 'path/toyour/project', build_number: current_build_number + 1)
davidrenji
  • 11
  • 3
0

I was trying to do the same thing, but could not find anything on how to achieve incrementing build number in the Swift Fastfile. However, I found a work around.

Note: I only wanted to increment build number and then push to TestFlight.

Work around:

  1. Setup Fastlane Swift (I chose the push to Beta setup). Docs here.
  2. In Terminal, run fastlane run increment_build_number to get increment the build number first.
  3. After that's done, run fastlane beta. This is only if your lane/function in the Fastfile is called betaLane(), change it accordingly. If it's called helloLane(), then use fastlane hello.

And you're done!

However, that's two commands, let's make it into one (optional, but nice):

  1. To wrap this into one command, create a shell script. First, enter into Terminal vim name_of_script.sh.
  2. Put both commands into your script: fastlane run increment_build_number; fastlane beta;
  3. Save and run your script!

If you get this error: Apple Generic Versioning is not enabled in this project then follow the directions here to enable it. It's really easy, just read it.

After all this, you should be able to push to TestFlight with an incremented build number with just one command!

Akash Kundu
  • 1,278
  • 13
  • 21