Skip to content

Instantly share code, notes, and snippets.

@adetamore
Last active August 29, 2015 13:57
Show Gist options
  • Save adetamore/9531894 to your computer and use it in GitHub Desktop.
Save adetamore/9531894 to your computer and use it in GitHub Desktop.
Auto Incrementing Build Version - iOS
#!/bin/bash
buildPlist=${INFOPLIST_FILE}
newVersion=`/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$buildPlist" | /usr/bin/perl -pe 's/(\d+)/($1+1)/eg'`
/usr/libexec/PListBuddy -c "Set :CFBundleVersion $newVersion" "$buildPlist"
Open Target > General
Set build number to 0 (or desired starting number)
Open Target > Build Phases
Editor > Add Build Phase > Add Run Script Build Phase
Shell: /bin/bash
Paste the shell script
NSDictionary *appInfo = [[NSBundle mainBundle] infoDictionary];
NSString *appVersion = [NSString stringWithFormat:@"%@.%@", appInfo[@"CFBundleShortVersionString"], appInfo[@"CFBundleVersion"]];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment