Fastlane build numbers for Unity

Recently on a project, I came across a problem where the Fastlane Unity action I am using was blowing away the info.plist of the generated xcode project despite the Unity project being marked as “Append” instead of “Replace”.

The reason this is a problem is we wanted each build to be uploaded to hockey app with a unique build number. Fastlane has plugins to handle this but it depends on the info.plist not being destroyed.

So there’s a simple hack to fix this. Use a small ruby function in the fastlane file to write your version to a file and update each time the file is ran.

Here’s a snippet:

build_num = 1
filename = "build_number"
if File.exist?(filename) { |f|
    build_num = + 1
end, "w") { |f|

When you want to get your version number you simply just :

file ="build_number", "r")
build_num =

And Bob's your uncle.