Automatically increment the build number of your project's version string.
In your info.plist you should already have the following:
• CFBundleShortVersionString (e.g., 1.0.0)
• CFBundleVersion (e.g., 1.0.0.133)
Step by step:
1. Enter your initial version values into the info.plist
Bundle versions string, short: 0.1.0 (CFBundleShortVersionString)
Bundle version: 0.1.0.1 (CFBundleVersion)
2. Select your Target in Xcode
3. Add a new run script build phase:
Project -> New Build Phase -> New Run Script Build Phase
4. Paste the script below into the script box
5. Build your project
version=$(sed -n '
/^[[:blank:]]*CFBundleShortVersionString<\/key>$/ {
N
s/^[[:blank:]]*CFBundleShortVersionString<\/key>\n[[:blank:]]*\(.*\)<\/string>/\1/
p
}' info.plist)
build=$(sed -n '
/^[[:blank:]]*CFBundleVersion<\/key>$/ {
N
s/^[[:blank:]]*CFBundleVersion<\/key>\n[[:blank:]]*.*\.\(.*\)<\/string>/\1/
p
}' info.plist)
build=$(($build +1))
cp Info.plist 'Backup of Info.plist'
sed '
/^[[:blank:]]*CFBundleVersion<\/key>$/ {
N
s/\(\).*\(<\/string>\)/\1'"$version\.$build"'\2/
P
D
}' 'Backup of info.plist' > Info.plist

