You will now write a new script, or lane, to automatically increment the version of your app in Android:
-
Open the android/fastlane/Fastfile file in your project.
-
In the file, identify the platform :android do section.
-
At the end of the section, before the end instruction, insert a new lane, called IncrementVersion:
lane :IncrementVersion do
end
- In the IncrementVersion lane, add the following instructions:
path = '../../pubspec.yaml'
re = /version:\s+(\d+)/
s = File.read(path)
versionCode = s[re, 1].to_i
s[re, 1] = (versionCode + 1).to_s
f = File.new(path, 'w')
f.write(s)
f.close
-
Open a terminal window and go to the android folder of your project.
-
From the terminal, run the following command:
fastlane IncrementBuildNumber
- Note the success message in the terminal: fastlane.tools finished successfully.