
SwiftVer



Manage versioning in MacOS, iOS, watchOS, and tvOS projects by parsing your bundle and revision metadata from your VCS repository.

Contents
Requirements
- XCode 8.0
- macOS 10.10+, iOS 8.1+, watchOS 2.0+
Installation
CocoaPods
CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:
$ gem install cocoapods
To integrate SwiftVer into your Xcode project using CocoaPods, specify it in your Podfile
:
use_frameworks!
pod 'SwiftVer'
Then, run the following command:
$ pod install
Carthage
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
You can install Carthage with Homebrew using the following command:
$ brew update
$ brew install carthage
To integrate SwiftVer into your Xcode project using Carthage, specify it in your Cartfile
:
github "brightdigit/SwiftVer" ~> 2.0.0
Run carthage update
to build the framework and drag the built SwiftVer.framework
into your Xcode project.
Usage
Parsing the Version from a Bundle
The Version
bundle initializer takes in a bundle and failable. If your Bundle does to contain a valid version string in the format of major.minor
or major.minor.patch
, the initializer will fail.
guard let version = Version(bundle: Bundle.main) else {
// invalid version format
}
Valid

Valid

Invalid

Integrating Version Control Info with Autorevision
You can revision metadata from your VCS repository using Autorevision.
Add the bash script from Autorevision.
Add a Run Script build phase to your project.
"${SRCROOT}/autorevision.sh" -t <format> >${SRCROOT}/framework/autorevision.<format>
Include the output in your bundle.
Parse the output and call the VersionControlInfo
initializer.
public struct VersionControlInfo {
public init(type: String,
baseName: String,
uuid: Hash?,
number: Int,
date: String,
branch: String,
tag: String?,
tick: Int?,
extra: String?,
hash: String,
isWorkingCopyModified: Bool)
}
Using a StageBuildDictionary to parse Stage
In version 2.0.0, you can parse the stage based on a StageBuildDictionary. The StageBuildDictionary is a plist which maps the Semantic Versions to Stages and their minimum build number.
Plist where the Build Number Resets at Each Semantic Version (iOS)

Plist where the Build Number does not Reset at Each Semantic Version (Sparkle-compatible macOS)

To create the dictionary pass it to the following method:
public enum Stage {
public static func dictionary(fromPlistAtURL url: URL) -> StageBuildDictionaryProtocol?
}
Documentation
Documentation Here
Author
Leo G Dion, BrightDigit, LLC
License
SwiftVer is available under the MIT license. See the LICENSE file for more info.
SwiftVer
Manage versioning in MacOS, iOS, watchOS, and tvOS projects by parsing your bundle and revision metadata from your VCS repository.
Contents
Requirements
Installation
CocoaPods
CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:
To integrate SwiftVer into your Xcode project using CocoaPods, specify it in your
Podfile
:Then, run the following command:
Carthage
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
You can install Carthage with Homebrew using the following command:
To integrate SwiftVer into your Xcode project using Carthage, specify it in your
Cartfile
:Run
carthage update
to build the framework and drag the builtSwiftVer.framework
into your Xcode project.Usage
Parsing the Version from a Bundle
The
Version
bundle initializer takes in a bundle and failable. If your Bundle does to contain a valid version string in the format ofmajor.minor
ormajor.minor.patch
, the initializer will fail.Valid
Valid
Invalid
Integrating Version Control Info with Autorevision
You can revision metadata from your VCS repository using Autorevision.
Add the bash script from Autorevision.
Add a Run Script build phase to your project.
Include the output in your bundle.
Parse the output and call the
VersionControlInfo
initializer.Using a StageBuildDictionary to parse Stage
In version 2.0.0, you can parse the stage based on a StageBuildDictionary. The StageBuildDictionary is a plist which maps the Semantic Versions to Stages and their minimum build number.
Plist where the Build Number Resets at Each Semantic Version (iOS)
Plist where the Build Number does not Reset at Each Semantic Version (Sparkle-compatible macOS)
To create the dictionary pass it to the following method:
Documentation
Documentation Here
Author
Leo G Dion, BrightDigit, LLC
License
SwiftVer is available under the MIT license. See the LICENSE file for more info.