This is used to increment a build number in a tracking file for use in a build / CI script:


def increment(filename)
    # Read it
    file_str = ''
    if File.exists?(filename)
        file_str =, 'r') {|file| }

    old_version = file_str.to_i
    new_version = old_version+1

    # Write, 'w') {|file| file.write(new_version) }

    puts "Incrementing version number in #{filename} to #{new_version}" 

if ARGV.length < 1
    puts 'Usage: VersionIncrement '

Thanks for reading! And if you want to get in touch, I'd love to hear from you: chris.hulbert at gmail.

Chris Hulbert

(Comp Sci, Hons - UTS)

iOS Developer (Freelancer / Contractor) in Australia.

I have worked at places such as Google, Cochlear, Assembly Payments, News Corp, Fox Sports, NineMSN, FetchTV, Coles, Woolworths, Trust Bank, and Westpac, among others. If you're looking for help developing an iOS app, drop me a line!

Get in touch:
[email protected]

 Subscribe via RSS