Going forward, if you look on the Info tab for your Application Target, you should use the "Bundle versions string, short" as your Version (e.g., 3.4.0) and "Bundle version" as your Build (e.g., 500 or 1A500). If you don't see them both, you can add them. Those will map to the proper Version and Build textboxes on the Summary tab.
There are all sorts of schemes, but a popular one is:
{MajorVersion}.{MinorVersion}.{Revision}
- Major version - Major changes, redesigns, and functionality changes
- Minor version - Minor improvements, additions to functionality
- Revision - A patch number for bug-fixe
Then the Build is used separately to indicate the total number of builds for a release or for the entire product lifetime.
Many developers start the Build number at 0, and every time they build they increase the number by one, increasing forever. In my projects, I have a script that automatically increases the build number every time I build. See instructions for that below.
- Release 1.0.0 might be build 542. It took 542 builds to get to a 1.0.0 release.
- Release 1.0.1 might be build 578.
- Release 1.1.0 might be build 694.
- Release 2.0.0 might be build 949.
Auto-incrementing build numbers in Xcode
It's a pain to build project in Xcode only to find out later that you forgot to update the build number.
In Xcode 4.2:
|
# echo $(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion"${PROJECT_DIR}/${PROJECT_NAME}/${PROJECT_NAME}-Info.plist)
echo "Current Build version $buildNumber"
(( buildNumber += 1 )) #increment build number by one
echo "New Build version $buildNumber"
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber"${PROJECT_DIR}/${PROJECT_NAME}/${PROJECT_NAME}-Info.plist
Note you can view the echo message at log navigator in xcode.
You can access the version information using the following code
--------------------------------------------------------------
NSString * version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
NSString * buildNo = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBuildNumber"];
NSString * buildDate = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBuildDate"];
NSLog(@"Application Version: %@ Build No: %@ Build Date: %@",version,buildNo,buildDate);
NSString * buildNo = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBuildNumber"];
NSString * buildDate = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBuildDate"];
NSLog(@"Application Version: %@ Build No: %@ Build Date: %@",version,buildNo,buildDate);
No comments:
Post a Comment