A few simple steps to make versioning more understandable
-
Every version string consists of 2 parts:
Bundle Version String
(fromInfo.plist
file) andGit commit SHA1
(you always can find this commit in the repository timeline). -
You can display your unique app version on the splash screen or on the about screen.
-
When you sending yet another build to your customers or testers, you're not afraid to get lost in application versions. Every bug or wish will be binded with the version code.
-
Your AppStore users can send feedbacks from the special form and every message will be signed with the unique version code.
This shell script runs every time you building your application. As the result - value of the macros GIT_SHA_VERSION
(from GitVersion.h
) updates with the SHA1-code
of the last branch commit.
-
Open
Build Phases
in Xcode -
Press
Add Build Phase
-
Press
Add Run Script Build Phase
. You can find this in the top menuEditor
. Drag script-line to the position afterTarget Dependencies
. -
Set Shell line to
/bin/sh
-
Set contents of the gitversionning.sh (without first #-lines) to the script field. Don't forget to change Sources to your path-to-file, where
GitVersion.h
should be. For example: -
Import
GitVersion.h
file into Xcode project -
Paste these lines:
#import "GitVersion.h"
NSDictionary *info = [[NSBundle mainBundle] infoDictionary];
NSString *version = [info objectForKey:@"CFBundleShortVersionString"];
NSString *app_version = [NSString stringWithFormat:@"%@.%@", version, GIT_SHA_VERSION];
NSLog(@"app_version : %@", app_version);
GitVersioningOnXCode is available under the MIT license.
Copyright © 2013 Ildar Sibagatov.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.