14 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
12 changed files with 152 additions and 18 deletions
+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"
+1 -1
View File
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = "Identifier"
spec.version = "1.0.0"
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"
+60 -9
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 */; };
@@ -151,6 +165,9 @@
LastUpgradeCheck = 1020;
ORGANIZATIONNAME = "Matt Rubin";
TargetAttributes = {
C9425DEB227555DC00EF93BD = {
CreatedOnToolsVersion = 10.2.1;
};
C97980F3224FE68800132BEC = {
CreatedOnToolsVersion = 10.2;
};
@@ -173,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;
@@ -205,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";
@@ -232,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";
@@ -294,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
+3 -3
View File
@@ -37,7 +37,7 @@ struct Comment: Equatable, Codable {
Add the following line to your [Cartfile][]:
````config
github "mattrubin/Identifier" ~> 1.0
github "mattrubin/Identifier" ~> 1.1
````
Then run `carthage update Identifier` to install the latest version of the framework.
@@ -53,7 +53,7 @@ Be sure to check the Carthage README file for the latest instructions on [adding
Add the following line to your [Podfile][]:
````ruby
pod 'Identifier', '~> 1.0'
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.
@@ -68,7 +68,7 @@ Then run `pod install` to install the latest version of the framework.
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.0.0"),
.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
+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.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.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),
]