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.swift
) 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 gitversioning.sh (without first #-lines) to the script field. Don't forget to change Sources to your path-to-file, where
GitVersion.swift
should be. For example: -
Add the autogenerated
GitVersion.swift
file into Xcode project -
Paste these lines:
let myCFBundleShortVersionString = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String
NSLog(myCFBundleShortVersionString! + "." + GIT_SHA_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.