53 Commits

Author SHA1 Message Date
Matt Rubin 03609ce6c5 Release Identifier 1.1.0 2019-04-28 23:38:36 -04:00
Matt Rubin 2367635a26 Merge pull request #23 from mattrubin/version-number
Bump the version number to 1.1.0
2019-04-28 23:13:06 -04:00
Matt Rubin 1ad2eda81e Bump the version number to 1.1.0 2019-04-28 22:50:47 -04:00
Matt Rubin 06265eacbe Merge pull request #22 from mattrubin/string-convertible
Add conformance to LosslessStringConvertible and CustomDebugStringConvertible
2019-04-28 22:38:07 -04:00
Matt Rubin 193cfda81b Add documentation comments to the string conversion methods 2019-04-28 21:05:56 -04:00
Matt Rubin 8a98345904 Add tests for LosslessStringConvertible conformance 2019-04-28 21:01:30 -04:00
Matt Rubin be47d08f35 Add conformance to LosslessStringConvertible 2019-04-28 20:52:08 -04:00
Matt Rubin f38f7744d5 Add a debugDescription test 2019-04-28 20:28:38 -04:00
Matt Rubin 69da13b577 Add conformance to CustomDebugStringConvertible 2019-04-28 20:21:47 -04:00
Matt Rubin f15450916b Merge pull request #21 from mattrubin/swiftlint-build-phase
Add a SwiftLint build phase
2019-04-28 00:53:25 -04:00
Matt Rubin 0a8e7b1e17 Add a SwiftLint build phase in a dedicated aggregate target
This setup allows the project to be linted on every build during development, because the lint target is included in the Identifier scheme's build list, but the linter will not be run on build if the framework is being built as a dependency of another project with its own scheme.
2019-04-27 23:36:45 -04:00
Matt Rubin e59fe9d421 Merge pull request #20 from mattrubin/xcconfigs
Upgrade xcconfigs
2019-04-06 00:02:10 -04:00
Matt Rubin 8654fd7dac Delete project build settings already present in the xcconfigs 2019-04-05 23:32:34 -04:00
Matt Rubin c1da9e7986 Upgrade xcconfigs 2019-04-05 23:26:36 -04:00
Matt Rubin 8205e964eb Identifier 1.0.0 2019-04-03 23:30:21 -04:00
Matt Rubin f2f271cd6a Bump the version number to 1.0 2019-04-03 18:23:09 -04:00
Matt Rubin 01e22dcf0b Merge pull request #18 from mattrubin/installation-instructions
Add installation instructions to the README
2019-04-03 16:15:15 -04:00
Matt Rubin a823fcd07f Add installation instructions to the README 2019-04-03 13:09:39 -04:00
Matt Rubin 666cb96f09 Merge pull request #17 from mattrubin/carthage-on-ci
Add a Carthage CI job
2019-04-03 12:25:23 -04:00
Matt Rubin c820d12476 Don't manually specify swift version for SPM builds on Travis
Until the project (maybe, eventually) supports building with multiple Swift versions, it's better to test that SPM is automatically using the correct Swift version as defined in the package manifest.
2019-04-03 11:33:55 -04:00
Matt Rubin 70264c5c07 Rename Carthage and CocoaPods Travis jobs for clarity 2019-04-03 11:31:59 -04:00
Matt Rubin d0f50d72af Rename Travis jobs to clarify build tool usage 2019-04-03 11:30:21 -04:00
Matt Rubin f2f16435d3 Add a carthage build --archive job to the Travis config 2019-04-03 11:16:17 -04:00
Matt Rubin 324773dfe6 Merge pull request #16 from mattrubin/install-path
Set the framework's INSTALL_PATH
2019-04-01 16:53:37 -04:00
Matt Rubin 64d0afd950 Use the platform-generic application xcconfig for IdentifierTests 2019-04-01 15:22:18 -04:00
Matt Rubin 50466fd82b Use the platform-generic framework xcconfig 2019-04-01 15:18:04 -04:00
Matt Rubin 0aaf67f803 Set the framework's INSTALL_PATH to @rpath
Without this build setting, an iOS app running on device was unable to find the embedded framework.
2019-04-01 15:09:07 -04:00
Matt Rubin 3580cc1e2d Merge pull request #15 from mattrubin/version-number
Set version number
2019-04-01 10:54:34 -04:00
Matt Rubin 77a7a79055 Update the version number in the podspec 2019-04-01 10:33:36 -04:00
Matt Rubin 3b97eb6d3d Set the project version to 0.1.1 2019-04-01 10:33:04 -04:00
Matt Rubin 83ef2cb330 Merge pull request #14 from mattrubin/podspec
Add a Podspec
2019-04-01 00:53:13 -04:00
Matt Rubin 19d7fee0ae Add a pod lib lint job to the Travis config 2019-04-01 00:33:21 -04:00
Matt Rubin 8951689e52 Add CocoaPods to the dependency manager badge in the README 2019-04-01 00:05:49 -04:00
Matt Rubin 9e0322aec9 Organize the podspec 2019-03-31 23:55:17 -04:00
Matt Rubin 48c45a4d30 Add a podspec 2019-03-31 23:50:44 -04:00
Matt Rubin e30a0d165d Merge pull request #13 from mattrubin/package-dependency
Use a more readable dependency versioning syntax in Package.swift
2019-03-31 22:59:04 -04:00
Matt Rubin d288d936a7 Use a more readable dependency versioning syntax in Package.swift
`.package(url: …, from: …)` is equivalent to `.package(url: …, .upToNextMajor(from: …))`
2019-03-31 22:42:43 -04:00
Matt Rubin d788cd3ba8 Merge pull request #12 from mattrubin/license
Add the MIT License
2019-03-31 21:49:30 -04:00
Matt Rubin 26c6fb7df0 Add a license note and badge to the README 2019-03-31 21:22:22 -04:00
Matt Rubin c0b28a88a2 Add a license file 2019-03-31 21:15:23 -04:00
Matt Rubin acc29bfc61 Merge pull request #11 from mattrubin/readme-badges
Add README badges
2019-03-31 21:08:11 -04:00
Matt Rubin 91f406c70f Adjust the color of the dependency manager badge 2019-03-31 20:47:14 -04:00
Matt Rubin ee50a31a67 Adjust the color of the platforms badge 2019-03-31 20:41:09 -04:00
Matt Rubin 60d22ba869 Use the develop branch for the code coverage badge 2019-03-31 20:40:51 -04:00
Matt Rubin d9aa9ec7a4 Use a code coverage badge without the Codecov icon in the README 2019-03-31 20:25:18 -04:00
Matt Rubin 63f44847cd Add a dependency manager badge to the README 2019-03-31 20:24:44 -04:00
Matt Rubin 73db351527 Add a supported platforms badge to the README 2019-03-31 20:23:54 -04:00
Matt Rubin a4e1b6c6b1 Add a Swift version badge to the README 2019-03-31 20:08:43 -04:00
Matt Rubin df26cbb8da Merge pull request #10 from mattrubin/swiftlint
Enable SwiftLint opt-in rules
2019-03-31 19:54:57 -04:00
Matt Rubin a5e2ca4cea Configure SwiftLint to allow function declarations to have long lines 2019-03-31 19:41:16 -04:00
Matt Rubin d544874009 Enable many SwiftLint opt-in rules 2019-03-31 19:28:07 -04:00
Matt Rubin d44f096362 Merge pull request #9 from mattrubin/swift-test-disable-automatic-resolution
Add the `--disable-automatic-resolution` flag to `swift test` CI jobs
2019-03-31 18:41:52 -04:00
Matt Rubin 69a816c86b Add the --disable-automatic-resolution flag to swift test CI jobs
This prevents SPM from updating the resolved package dependencies, which will cause the CI job to fail if Package.resolved is out of date.

https://developer.apple.com/documentation/xcode_release_notes/xcode_10_2_release_notes/swift_5_release_notes_for_xcode_10_2#3136858
2019-03-31 18:11:13 -04:00
16 changed files with 337 additions and 44 deletions
+67
View File
@@ -6,5 +6,72 @@ excluded:
- Tests/LinuxMain.swift
- Tests/IdentifierTests/XCTestManifests.swift
opt_in_rules:
- array_init
- attributes
- closure_body_length
- closure_end_indentation
- closure_spacing
- collection_alignment
- conditional_returns_on_newline
- contains_over_first_not_nil
- convenience_type
- discouraged_object_literal
- discouraged_optional_boolean
- discouraged_optional_collection
- empty_count
- empty_string
- empty_xctest_method
- explicit_enum_raw_value
- explicit_init
- extension_access_modifier
- fallthrough
- fatal_error_message
- file_name
- first_where
- function_default_parameter_at_end
- identical_operands
- implicit_return
- implicitly_unwrapped_optional
- joined_default_parameter
- last_where
- legacy_random
- let_var_whitespace
- literal_expression_end_indentation
- lower_acl_than_parent
- modifier_order
- multiline_arguments
- multiline_function_chains
- multiline_literal_brackets
- multiline_parameters
- nimble_operator
- nslocalizedstring_key
- operator_usage_whitespace
- overridden_super_call
- override_in_extension
- pattern_matching_keywords
- prohibited_super_call
- redundant_nil_coalescing
- redundant_type_annotation
- single_test_class
- sorted_first_last
- static_operator
- strict_fileprivate
- switch_case_on_newline
- toggle_bool
- unavailable_function
- untyped_error_in_catch
- unused_import
- unused_private_declaration
- vertical_parameter_alignment_on_call
- vertical_whitespace_between_cases
- vertical_whitespace_closing_braces
- vertical_whitespace_opening_braces
- xct_specific_matcher
- yoda_condition
line_length:
ignores_function_declarations: true
trailing_comma:
mandatory_comma: true
+16 -8
View File
@@ -12,33 +12,41 @@ jobs:
include:
- stage: pretest
name: Validate Linux test manifest
install: swift test --generate-linuxmain
install: swift test --generate-linuxmain --disable-automatic-resolution
script: git diff --exit-code
- &spm
stage: test
name: macOS / SPM 5.0 / Swift 5.0
script: swift test -Xswiftc -swift-version -Xswiftc 5
name: SPM @ Xcode 10.2 / macOS
script: swift test --disable-automatic-resolution
- <<: *spm
name: Linux / SPM 5.0 / Swift 5.0
name: SPM 5.0 / Linux
os: linux
language: generic
env: SWIFT_VERSION=5.0
install: eval "$(curl -sL https://swiftenv.fuller.li/install.sh)"
- &cocoapods
name: CocoaPods & Xcode 10.2 / pod lib lint
script: pod lib lint
- &carthage
name: Carthage & Xcode 10.2 / carthage build --archive
script: carthage build --archive
- &xcode
name: macOS / Xcode 10.2 / Swift 5.0
name: Xcode 10.2 / macOS
xcode_workspace: Identifier.xcworkspace
xcode_scheme: Identifier
xcode_destination: 'platform=macOS'
- <<: *xcode
name: iOS / Xcode 10.2 / Swift 5.0
name: Xcode 10.2 / iOS
xcode_destination: 'OS=12.2,name=iPhone SE'
- <<: *xcode
name: tvOS / Xcode 10.2 / Swift 5.0
name: Xcode 10.2 / tvOS
xcode_destination: 'OS=12.2,name=Apple TV'
- <<: *xcode
name: watchOS / Xcode 10.2 / Swift 5.0
name: Xcode 10.2 / watchOS
xcode_destination: 'OS=5.2,name=Apple Watch Series 2 - 38mm'
script: set -o pipefail && xcodebuild -workspace "$TRAVIS_XCODE_WORKSPACE" -scheme "$TRAVIS_XCODE_SCHEME" -destination "$TRAVIS_XCODE_DESTINATION" build | xcpretty
+1 -1
View File
@@ -1,4 +1,4 @@
# Configuration for Carthage (https://github.com/Carthage/Carthage)
github "jspahrsummers/xcconfigs"
github "jspahrsummers/xcconfigs" ~> 1.0
github "Quick/Nimble" ~> 8.0
+1 -1
View File
@@ -1,2 +1,2 @@
github "Quick/Nimble" "v8.0.1"
github "jspahrsummers/xcconfigs" "0.12"
github "jspahrsummers/xcconfigs" "1.0"
+19
View File
@@ -0,0 +1,19 @@
Pod::Spec.new do |spec|
spec.name = "Identifier"
spec.version = "1.1.0"
spec.summary = "Unique, strongly-typed identifiers in Swift."
spec.description = "`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."
spec.homepage = "https://github.com/mattrubin/Identifier"
spec.license = { :type => "MIT", :file => "LICENSE.md" }
spec.author = "Matt Rubin"
spec.source = { :git => "https://github.com/mattrubin/Identifier.git", :tag => "#{spec.version}" }
spec.source_files = "Sources/Identifier/**/*.swift"
spec.frameworks = "Foundation"
spec.swift_version = "5.0"
spec.ios.deployment_target = "8.0"
spec.osx.deployment_target = "10.10"
spec.tvos.deployment_target = "9.0"
spec.watchos.deployment_target = "2.0"
end
+68 -29
View File
@@ -6,6 +6,20 @@
objectVersion = 50;
objects = {
/* Begin PBXAggregateTarget section */
C9425DEB227555DC00EF93BD /* Lint Identifier */ = {
isa = PBXAggregateTarget;
buildConfigurationList = C9425DEE227555DD00EF93BD /* Build configuration list for PBXAggregateTarget "Lint Identifier" */;
buildPhases = (
C9425DEF227555EA00EF93BD /* Run SwiftLint */,
);
dependencies = (
);
name = "Lint Identifier";
productName = "Lint Identifier";
};
/* End PBXAggregateTarget section */
/* Begin PBXBuildFile section */
C97980FE224FE68800132BEC /* Identifier.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C97980F4224FE68800132BEC /* Identifier.framework */; };
C9798103224FE68800132BEC /* IdentifierTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9798102224FE68800132BEC /* IdentifierTests.swift */; };
@@ -24,6 +38,8 @@
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
C950E96522529A2500583754 /* Framework.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Framework.xcconfig; path = Base/Targets/Framework.xcconfig; sourceTree = "<group>"; };
C950E96622529BA500583754 /* Application.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Application.xcconfig; path = Base/Targets/Application.xcconfig; sourceTree = "<group>"; };
C97980F4224FE68800132BEC /* Identifier.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Identifier.framework; sourceTree = BUILT_PRODUCTS_DIR; };
C97980F7224FE68800132BEC /* Identifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Identifier.swift; sourceTree = "<group>"; };
C97980FD224FE68800132BEC /* IdentifierTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = IdentifierTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -89,6 +105,8 @@
children = (
C979812C224FF07C00132BEC /* Debug.xcconfig */,
C979812D224FF07C00132BEC /* Release.xcconfig */,
C950E96522529A2500583754 /* Framework.xcconfig */,
C950E96622529BA500583754 /* Application.xcconfig */,
);
name = Configurations;
path = Carthage/Checkouts/xcconfigs;
@@ -147,6 +165,9 @@
LastUpgradeCheck = 1020;
ORGANIZATIONNAME = "Matt Rubin";
TargetAttributes = {
C9425DEB227555DC00EF93BD = {
CreatedOnToolsVersion = 10.2.1;
};
C97980F3224FE68800132BEC = {
CreatedOnToolsVersion = 10.2;
};
@@ -169,10 +190,32 @@
targets = (
C97980F3224FE68800132BEC /* Identifier */,
C97980FC224FE68800132BEC /* IdentifierTests */,
C9425DEB227555DC00EF93BD /* Lint Identifier */,
);
};
/* End PBXProject section */
/* Begin PBXShellScriptBuildPhase section */
C9425DEF227555EA00EF93BD /* Run SwiftLint */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = "Run SwiftLint";
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint is not installed. (https://github.com/realm/SwiftLint)\"\nfi\n";
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
C97980F0224FE68800132BEC /* Sources */ = {
isa = PBXSourcesBuildPhase;
@@ -201,18 +244,26 @@
/* End PBXTargetDependency section */
/* Begin XCBuildConfiguration section */
C9425DEC227555DD00EF93BD /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
};
name = Debug;
};
C9425DED227555DD00EF93BD /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
};
name = Release;
};
C9798106224FE68800132BEC /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = C979812C224FF07C00132BEC /* Debug.xcconfig */;
buildSettings = {
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = dwarf;
GCC_DYNAMIC_NO_PIC = NO;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MACOSX_DEPLOYMENT_TARGET = 10.10;
SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator";
@@ -228,14 +279,9 @@
isa = XCBuildConfiguration;
baseConfigurationReference = C979812D224FF07C00132BEC /* Release.xcconfig */;
buildSettings = {
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
ENABLE_NS_ASSERTIONS = NO;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MACOSX_DEPLOYMENT_TARGET = 10.10;
SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator";
@@ -249,39 +295,29 @@
};
C9798109224FE68800132BEC /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = C950E96522529A2500583754 /* Framework.xcconfig */;
buildSettings = {
APPLICATION_EXTENSION_API_ONLY = YES;
DEFINES_MODULE = YES;
INFOPLIST_FILE = Sources/Identifier/Info.plist;
PRODUCT_BUNDLE_IDENTIFIER = "me.mattrubin.$(PRODUCT_NAME:c99extidentifier)";
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
};
name = Debug;
};
C979810A224FE68800132BEC /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = C950E96522529A2500583754 /* Framework.xcconfig */;
buildSettings = {
APPLICATION_EXTENSION_API_ONLY = YES;
DEFINES_MODULE = YES;
INFOPLIST_FILE = Sources/Identifier/Info.plist;
PRODUCT_BUNDLE_IDENTIFIER = "me.mattrubin.$(PRODUCT_NAME:c99extidentifier)";
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
};
name = Release;
};
C979810C224FE68800132BEC /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = C950E96622529BA500583754 /* Application.xcconfig */;
buildSettings = {
INFOPLIST_FILE = Tests/IdentifierTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
"@executable_path/../Frameworks",
"@loader_path/../Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = "me.mattrubin.$(PRODUCT_NAME:c99extidentifier)";
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
};
@@ -289,15 +325,9 @@
};
C979810D224FE68800132BEC /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = C950E96622529BA500583754 /* Application.xcconfig */;
buildSettings = {
INFOPLIST_FILE = Tests/IdentifierTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
"@executable_path/../Frameworks",
"@loader_path/../Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = "me.mattrubin.$(PRODUCT_NAME:c99extidentifier)";
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
};
@@ -306,6 +336,15 @@
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
C9425DEE227555DD00EF93BD /* Build configuration list for PBXAggregateTarget "Lint Identifier" */ = {
isa = XCConfigurationList;
buildConfigurations = (
C9425DEC227555DD00EF93BD /* Debug */,
C9425DED227555DD00EF93BD /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
C97980EE224FE68800132BEC /* Build configuration list for PBXProject "Identifier" */ = {
isa = XCConfigurationList;
buildConfigurations = (
@@ -20,6 +20,20 @@
ReferencedContainer = "container:Identifier.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C9425DEB227555DC00EF93BD"
BuildableName = "Lint Identifier"
BlueprintName = "Lint Identifier"
ReferencedContainer = "container:Identifier.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 Matt Rubin
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.
+1 -1
View File
@@ -14,7 +14,7 @@ let package = Package(
.library(name: "Identifier", targets: ["Identifier"]),
],
dependencies: [
.package(url: "https://github.com/Quick/Nimble.git", .upToNextMajor(from: "8.0.0")),
.package(url: "https://github.com/Quick/Nimble.git", from: "8.0.0"),
],
targets: [
.target(name: "Identifier"),
+57 -1
View File
@@ -2,7 +2,11 @@
### Unique, strongly-typed identifiers in Swift.
[![Build Status](https://travis-ci.com/mattrubin/Identifier.svg?branch=develop)](https://travis-ci.com/mattrubin/Identifier)
[![codecov](https://codecov.io/gh/mattrubin/Identifier/branch/develop/graph/badge.svg)](https://codecov.io/gh/mattrubin/Identifier)
[![Codecov](https://img.shields.io/codecov/c/github/mattrubin/Identifier/develop.svg)](https://codecov.io/gh/mattrubin/Identifier)
![Swift 5.0](https://img.shields.io/badge/swift-5.0-orange.svg)
![Available via Carthage, CocoaPods, or SPM](https://img.shields.io/badge/via-Carthage%20%7C%20CocoaPods%20%7C%20SPM-MediumSlateBlue.svg)
![Platforms: iOS, macOS, tvOS, watchOS, Linux](https://img.shields.io/badge/platforms-iOS%20%7C%20macOS%20%7C%20tvOS%20%7C%20watchOS%20%7C%20Linux-blue.svg)
[![MIT License](https://img.shields.io/badge/license-MIT-lightgray.svg)](LICENSE.md)
`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.
@@ -24,3 +28,55 @@ struct Comment: Equatable, Codable {
let date: Date
}
```
## Installation
### [Carthage][]
Add the following line to your [Cartfile][]:
````config
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][carthage-instructions].
[Carthage]: https://github.com/Carthage/Carthage
[Cartfile]: https://github.com/Carthage/Carthage/blob/master/Documentation/Artifacts.md#cartfile
[carthage-instructions]: https://github.com/Carthage/Carthage/blob/master/README.md#adding-frameworks-to-an-application
### [CocoaPods][]
Add the following line to your [Podfile][]:
````ruby
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.
[CocoaPods]: https://cocoapods.org
[Podfile]: https://guides.cocoapods.org/using/the-podfile.html
### [SPM][]
Add the following line to the dependencies section of your [package manifest][Package.swift]:
```swift
.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
[SPM]: https://swift.org/package-manager/
[Package.swift]: https://github.com/apple/swift-package-manager/tree/master/Documentation
## License
Identifier is released under the [MIT License](LICENSE.md).
+24
View File
@@ -12,6 +12,30 @@ public struct Identifier<T>: Equatable, Hashable {
}
}
// MARK: - String Convertible
extension Identifier: LosslessStringConvertible {
/// Instantiates an identifier from a string representation.
public init?(_ description: String) {
guard let uuid = UUID(uuidString: description) else {
return nil
}
self.init(uuid: uuid)
}
/// A string representation of this identifier.
public var description: String {
return uuid.uuidString
}
}
extension Identifier: CustomDebugStringConvertible {
/// A detailed string representation of this identifier, for use in debugging.
public var debugDescription: String {
return "Identifier<\(T.self)>(uuid: \(uuid))"
}
}
// MARK: - Codable
extension Identifier: Codable {
+1 -1
View File
@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>1.1.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
</dict>
@@ -39,6 +39,48 @@ final class IdentifierTests: XCTestCase {
XCTAssertNotEqual(third, fourth)
}
// MARK: - String Convertible
func testInitWithDescription() {
let firstFromUUID = Identifier<Int>(uuid: firstUUID)
let firstDescription = "B9212942-B5B9-4547-A994-375921769411"
let firstFromDescription = Identifier<Int>(firstDescription)
XCTAssertEqual(firstFromDescription, firstFromUUID)
let secondRandom = Identifier<String>.random()
let secondDescription = secondRandom.uuid.uuidString
let secondFromDescription = Identifier<String>(secondDescription)
XCTAssertEqual(secondFromDescription, secondRandom)
let validDescription = UUID().uuidString
let validIdentifier = Identifier<Float>(validDescription)
XCTAssertNotNil(validIdentifier)
let invalidDescription = "12345"
let invalidIdentifier = Identifier<Float>(invalidDescription)
XCTAssertNil(invalidIdentifier)
}
func testDescription() {
let first = Identifier<Int>(uuid: firstUUID)
let firstExpectedDebugDescription = "B9212942-B5B9-4547-A994-375921769411"
XCTAssertEqual(first.description, firstExpectedDebugDescription)
let second = Identifier<String>.random()
let secondExpectedDebugDescription = second.uuid.uuidString
XCTAssertEqual(second.description, secondExpectedDebugDescription)
}
func testDebugDescription() {
let first = Identifier<Int>(uuid: firstUUID)
let firstExpectedDebugDescription = "Identifier<Int>(uuid: B9212942-B5B9-4547-A994-375921769411)"
XCTAssertEqual(first.debugDescription, firstExpectedDebugDescription)
let second = Identifier<String>.random()
let secondExpectedDebugDescription = "Identifier<String>(uuid: " + second.uuid.uuidString + ")"
XCTAssertEqual(second.debugDescription, secondExpectedDebugDescription)
}
// MARK: - Codable
func testEncode() {
+1 -1
View File
@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>1.1.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
</dict>
@@ -6,9 +6,12 @@ extension IdentifierTests {
// `swift test --generate-linuxmain`
// to regenerate.
static let __allTests__IdentifierTests = [
("testDebugDescription", testDebugDescription),
("testDecode", testDecode),
("testDescription", testDescription),
("testEncode", testEncode),
("testEquality", testEquality),
("testInitWithDescription", testInitWithDescription),
("testInitWithUUID", testInitWithUUID),
("testRandomIdentifier", testRandomIdentifier),
]