Swiftpack.co - mattrubin/Identifier as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by mattrubin.
mattrubin/Identifier 1.1.0
🧬 Unique, strongly-typed identifiers in Swift.
⭐️ 1
🕓 3 years ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/mattrubin/Identifier.git", from: "1.1.0")

Identifier

Unique, strongly-typed identifiers in Swift.

Build Status Codecov Swift 5.0 Available via Carthage, CocoaPods, or SPM Platforms: iOS, macOS, tvOS, watchOS, Linux MIT License

Identifier is a generic struct backed by a UUID, which can be specialized for the model type it identifies and provides unique, decentralized identity in a value type. It is Equatable, Hashable, and Codable, serializing to a simple UUID string.

Instead of using string identifiers in your models:

struct Comment: Equatable, Codable {
    let postID: String
    let authorID: String
    let text: String
    let date: Date
}

You can use typed identifiers, which help ensure an ID for a model of one type is never accidentally used in place of another:

struct Comment: Equatable, Codable {
    let postID: Identifier<Post>
    let authorID: Identifier<User>
    let text: String
    let date: Date
}

Installation

Carthage

Add the following line to your Cartfile:

github "mattrubin/Identifier" ~> 1.1

Then run carthage update Identifier to install the latest version of the framework.

Be sure to check the Carthage README file for the latest instructions on adding frameworks to an application.

CocoaPods

Add the following line to your Podfile:

pod 'Identifier', '~> 1.1'

Identifier, like all pods written in Swift, can only be integrated as a framework. Make sure to add the line use_frameworks! to your Podfile or target to opt into frameworks instead of static libraries.

Then run pod install to install the latest version of the framework.

SPM

Add the following line to the dependencies section of your package manifest:

.package(url: "https://github.com/mattrubin/Identifier.git", from: "1.1.0"),

Then add "Identifier" to the dependencies array of any target which should be linked with this library.

License

Identifier is released under the MIT License.

GitHub

link
Stars: 1
Last commit: 3 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

1.1.0
4 years ago
  • Upgrade xcconfigs
  • Add a SwiftLint build phase
  • Add conformance to LosslessStringConvertible and CustomDebugStringConvertible

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics