https://github.com/brightdigit/swiftver
Easily Manage Versioning in MacOS, iOS, watchOS, and tvOS projects.
https://github.com/brightdigit/swiftver
carthage cocoapods ios macos plist swift tvos watchos xcode
Last synced: 3 months ago
JSON representation
Easily Manage Versioning in MacOS, iOS, watchOS, and tvOS projects.
- Host: GitHub
- URL: https://github.com/brightdigit/swiftver
- Owner: brightdigit
- License: mit
- Created: 2015-11-25T18:20:12.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2020-02-29T18:49:47.000Z (over 5 years ago)
- Last Synced: 2025-06-20T23:22:10.767Z (4 months ago)
- Topics: carthage, cocoapods, ios, macos, plist, swift, tvos, watchos, xcode
- Language: Swift
- Homepage: www.swiftver.com
- Size: 1.61 MB
- Stars: 23
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

# SwiftVer
[](https://swift.org)
[](http://twitter.com/brightdigit)


[](https://beerpay.io/brightdigit/SwiftVer)
[](https://github.com/igrigorik/ga-beacon)


[](https://codecov.io/gh/brightdigit/swiftver)

[](https://codebeat.co/projects/github-com-brightdigit-swiftver-master)


[](https://cocoapods.org/pods/SwiftVer)
[](https://cocoapods.org/pods/SwiftVer)
[](https://cocoapods.org/pods/SwiftVer)
[](https://cocoapods.org/pods/SwiftVer)
[](https://github.com/Carthage/Carthage)
[](https://houndci.com)Manage versioning in MacOS, iOS, watchOS, and tvOS projects by parsing your bundle and revision metadata from your VCS repository.

## Contents
- [Requirements](#requirements)
- [Installation](#installation)
- [CocoaPods](#cocoapods)
- [Carthage](#carthage)
- [Usage](#usage)
- [Parsing the Version from a Bundle](#parsing-the-version-from-a-bundle)
- [Integrating Version Control Info with Autorevision](#integrating-version-control-info-with-autorevision)
- [Using a StageBuildDictionary to parse Stage](#using-a-stagebuilddictionary-to-parse-stage)
- [Documentation](/docs/README.md)
- [Author](#author)
- [License](#license)## Requirements
- XCode 8.0
- macOS 10.10+, iOS 8.1+, watchOS 2.0+## Installation
### CocoaPods
[CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. You can install it with the following command:
```bash
$ gem install cocoapods
```To integrate SwiftVer into your Xcode project using CocoaPods, specify it in your `Podfile`:
```ruby
use_frameworks!pod 'SwiftVer'
```Then, run the following command:
```bash
$ pod install
```### Carthage
[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
You can install Carthage with [Homebrew](http://brew.sh/) using the following command:
```bash
$ brew update
$ brew install carthage
```To integrate SwiftVer into your Xcode project using Carthage, specify it in your `Cartfile`:
```ogdl
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.
```swift
guard let version = Version(bundle: Bundle.main) else {
// invalid version format
}```
#### Valid
#### Valid
#### Invalid
### Integrating Version Control Info with [Autorevision](https://autorevision.github.io)
You can revision metadata from your VCS repository using [Autorevision](https://autorevision.github.io).
1. Add the bash script from [Autorevision](https://autorevision.github.io).
2. Add a Run Script build phase to your project.
``` base
"${SRCROOT}/autorevision.sh" -t >${SRCROOT}/framework/autorevision.
```3. Include the output in your bundle.
4. Parse the output and call the `VersionControlInfo` initializer.
``` swift
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:
``` swift
public enum Stage {
public static func dictionary(fromPlistAtURL url: URL) -> StageBuildDictionaryProtocol?
}
```## Documentation
[Documentation Here](/docs/README.md)
## Author
Leo G Dion, [BrightDigit, LLC](http://www.brightdigit.com)
## License
SwiftVer is available under the MIT license. See the LICENSE file for more info.