diff --git a/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Package.resolved b/Package.resolved new file mode 100644 index 0000000..9e8c8d4 --- /dev/null +++ b/Package.resolved @@ -0,0 +1,61 @@ +{ + "object": { + "pins": [ + { + "package": "Chalk", + "repositoryURL": "https://github.com/mxcl/Chalk.git", + "state": { + "branch": null, + "revision": "9aa9f348b86db3cf6702a3e43c081ecec80cf3c7", + "version": "0.4.0" + } + }, + { + "package": "FileCheck", + "repositoryURL": "https://github.com/llvm-swift/FileCheck.git", + "state": { + "branch": null, + "revision": "0dc8a5bff1a7f01e1d7bcc20c79e2127b2ea3eeb", + "version": "0.2.5" + } + }, + { + "package": "Nimble", + "repositoryURL": "https://github.com/Quick/Nimble.git", + "state": { + "branch": null, + "revision": "7a46a5fc86cb917f69e3daf79fcb045283d8f008", + "version": "8.1.2" + } + }, + { + "package": "Quick", + "repositoryURL": "https://github.com/Quick/Quick.git", + "state": { + "branch": null, + "revision": "09b3becb37cb2163919a3842a4c5fa6ec7130792", + "version": "2.2.1" + } + }, + { + "package": "swift-argument-parser", + "repositoryURL": "https://github.com/apple/swift-argument-parser", + "state": { + "branch": null, + "revision": "9564d61b08a5335ae0a36f789a7d71493eacadfc", + "version": "0.3.2" + } + }, + { + "package": "SwiftCheck", + "repositoryURL": "https://github.com/typelift/SwiftCheck.git", + "state": { + "branch": null, + "revision": "077c096c3ddfc38db223ac8e525ad16ffb987138", + "version": "0.12.0" + } + } + ] + }, + "version": 1 +} diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..8f4fb50 --- /dev/null +++ b/Package.swift @@ -0,0 +1,34 @@ +// swift-tools-version:5.3 +import PackageDescription + +let package = Package( + name: "TrueTime", + products: [ + .library( + name: "TrueTime", + targets: ["TrueTime"]), + .library( + name: "CTrueTime", + targets: ["CTrueTime"]) + ], + dependencies: [ + .package(url: "https://github.com/Quick/Nimble.git", .upToNextMajor(from: "8.0.1")), + .package(url: "https://github.com/Quick/Quick.git", .upToNextMajor(from: "2.1.0")), + .package(url: "https://github.com/typelift/SwiftCheck.git", .upToNextMajor(from: "0.12.0")), + ], + targets: [ + .target( + name: "TrueTime", + dependencies: ["CTrueTime"]), + .testTarget( + name: "TrueTimeTests", + dependencies: [ + "TrueTime", + "Quick", + "Nimble", + "SwiftCheck" + ] + ), + .systemLibrary(name: "CTrueTime") + ] +) diff --git a/Sources/TrueTime.h b/Sources/TrueTime.h deleted file mode 100644 index a9b09ab..0000000 --- a/Sources/TrueTime.h +++ /dev/null @@ -1,26 +0,0 @@ -// -// TrueTime.h -// TrueTime -// -// Created by Michael Sanders on 7/9/16. -// Copyright © 2016 Instacart. All rights reserved. -// - -@import Foundation; -#import "ntp_types.h" - -NS_ASSUME_NONNULL_BEGIN - -//! Project version number for TrueTime. -FOUNDATION_EXPORT double TrueTimeVersionNumber; - -//! Project version string for TrueTime. -FOUNDATION_EXPORT const unsigned char TrueTimeVersionNumberString[]; - -//! Domain for TrueTime errors. -FOUNDATION_EXPORT NSString * const TrueTimeErrorDomain; - -//! Notification sent whenever a TrueTimeClient's reference time is updated. -FOUNDATION_EXPORT NSString * const TrueTimeUpdatedNotification; - -NS_ASSUME_NONNULL_END diff --git a/Sources/TrueTime.m b/Sources/TrueTime.m deleted file mode 100644 index a8f2647..0000000 --- a/Sources/TrueTime.m +++ /dev/null @@ -1,12 +0,0 @@ -// -// TrueTime.m -// TrueTime -// -// Created by Michael Sanders on 8/15/16. -// Copyright © 2016 Instacart. All rights reserved. -// - -#import "TrueTime.h" - -NSString * const TrueTimeErrorDomain = @"com.instacart.TrueTimeErrorDomain"; -NSString * const TrueTimeUpdatedNotification = @"TrueTimeUpdatedNotification"; diff --git a/Sources/Endian.swift b/Sources/TrueTime/Endian.swift similarity index 99% rename from Sources/Endian.swift rename to Sources/TrueTime/Endian.swift index 348fa59..c65c8e4 100644 --- a/Sources/Endian.swift +++ b/Sources/TrueTime/Endian.swift @@ -7,6 +7,7 @@ // import Foundation +import CTrueTime protocol NetworkOrderConvertible { var byteSwapped: Self { get } diff --git a/Sources/GCDLock.swift b/Sources/TrueTime/GCDLock.swift similarity index 100% rename from Sources/GCDLock.swift rename to Sources/TrueTime/GCDLock.swift diff --git a/Sources/HostResolver.swift b/Sources/TrueTime/HostResolver.swift similarity index 100% rename from Sources/HostResolver.swift rename to Sources/TrueTime/HostResolver.swift diff --git a/Sources/Info.plist b/Sources/TrueTime/Info.plist similarity index 100% rename from Sources/Info.plist rename to Sources/TrueTime/Info.plist diff --git a/Sources/NTPClient.swift b/Sources/TrueTime/NTPClient.swift similarity index 99% rename from Sources/NTPClient.swift rename to Sources/TrueTime/NTPClient.swift index e340749..77fa64e 100644 --- a/Sources/NTPClient.swift +++ b/Sources/TrueTime/NTPClient.swift @@ -6,6 +6,9 @@ // Copyright © 2016 Instacart. All rights reserved. // +import Foundation +import CTrueTime + struct NTPConfig { let timeout: TimeInterval let maxRetries: Int diff --git a/Sources/NTPConnection.swift b/Sources/TrueTime/NTPConnection.swift similarity index 99% rename from Sources/NTPConnection.swift rename to Sources/TrueTime/NTPConnection.swift index 2606da3..7d02df0 100644 --- a/Sources/NTPConnection.swift +++ b/Sources/TrueTime/NTPConnection.swift @@ -7,6 +7,7 @@ // import Foundation +import CTrueTime typealias NTPConnectionCallback = (NTPConnection, FrozenNetworkTimeResult) -> Void diff --git a/Sources/NTPExtensions.swift b/Sources/TrueTime/NTPExtensions.swift similarity index 99% rename from Sources/NTPExtensions.swift rename to Sources/TrueTime/NTPExtensions.swift index c7d5088..7a94f79 100644 --- a/Sources/NTPExtensions.swift +++ b/Sources/TrueTime/NTPExtensions.swift @@ -7,6 +7,7 @@ // import Foundation +import CTrueTime public extension timeval { static func uptime() -> timeval { diff --git a/Sources/NTPResponse.swift b/Sources/TrueTime/NTPResponse.swift similarity index 99% rename from Sources/NTPResponse.swift rename to Sources/TrueTime/NTPResponse.swift index b9bc6d9..c3b2f72 100644 --- a/Sources/NTPResponse.swift +++ b/Sources/TrueTime/NTPResponse.swift @@ -7,6 +7,7 @@ // import Foundation +import CTrueTime struct NTPResponse { let packet: ntp_packet_t diff --git a/Sources/Reachability.swift b/Sources/TrueTime/Reachability.swift similarity index 100% rename from Sources/Reachability.swift rename to Sources/TrueTime/Reachability.swift diff --git a/Sources/ReferenceTime.swift b/Sources/TrueTime/ReferenceTime.swift similarity index 98% rename from Sources/ReferenceTime.swift rename to Sources/TrueTime/ReferenceTime.swift index f187b25..bcd95bd 100644 --- a/Sources/ReferenceTime.swift +++ b/Sources/TrueTime/ReferenceTime.swift @@ -6,6 +6,9 @@ // Copyright © 2016 Instacart. All rights reserved. // +import Foundation +import CTrueTime + typealias FrozenTimeResult = Result typealias FrozenTimeCallback = (FrozenTimeResult) -> Void diff --git a/Sources/SocketAddress.swift b/Sources/TrueTime/SocketAddress.swift similarity index 100% rename from Sources/SocketAddress.swift rename to Sources/TrueTime/SocketAddress.swift diff --git a/Sources/TimedOperation.swift b/Sources/TrueTime/TimedOperation.swift similarity index 100% rename from Sources/TimedOperation.swift rename to Sources/TrueTime/TimedOperation.swift diff --git a/Sources/TrueTime.swift b/Sources/TrueTime/TrueTime.swift similarity index 96% rename from Sources/TrueTime.swift rename to Sources/TrueTime/TrueTime.swift index a588a4e..04793f6 100644 --- a/Sources/TrueTime.swift +++ b/Sources/TrueTime/TrueTime.swift @@ -8,6 +8,12 @@ import Foundation +let TrueTimeErrorDomain = "com.instacart.TrueTimeErrorDomain" + +public extension Notification.Name { + static let TrueTimeUpdated = Notification.Name.init("TrueTimeUpdatedNotification") +} + @objc public enum TrueTimeError: Int { case cannotFindHost case dnsLookupFailed diff --git a/Tests/ArbitraryExtensions.swift b/Tests/TrueTimeTests/ArbitraryExtensions.swift similarity index 96% rename from Tests/ArbitraryExtensions.swift rename to Tests/TrueTimeTests/ArbitraryExtensions.swift index e7737cb..da920d1 100644 --- a/Tests/ArbitraryExtensions.swift +++ b/Tests/TrueTimeTests/ArbitraryExtensions.swift @@ -7,6 +7,7 @@ // @testable import TrueTime +import CTrueTime import SwiftCheck extension timeval: Arbitrary { diff --git a/Tests/Info.plist b/Tests/TrueTimeTests/Info.plist similarity index 100% rename from Tests/Info.plist rename to Tests/TrueTimeTests/Info.plist diff --git a/Tests/NTPExtensionsSpec.swift b/Tests/TrueTimeTests/NTPExtensionsSpec.swift similarity index 97% rename from Tests/NTPExtensionsSpec.swift rename to Tests/TrueTimeTests/NTPExtensionsSpec.swift index 6107abb..e49d0a0 100644 --- a/Tests/NTPExtensionsSpec.swift +++ b/Tests/TrueTimeTests/NTPExtensionsSpec.swift @@ -7,6 +7,7 @@ // @testable import TrueTime +import CTrueTime import Nimble import Quick import SwiftCheck diff --git a/Tests/NTPIntegrationSpec.swift b/Tests/TrueTimeTests/NTPIntegrationSpec.swift similarity index 99% rename from Tests/NTPIntegrationSpec.swift rename to Tests/TrueTimeTests/NTPIntegrationSpec.swift index 346f8e7..81c762a 100644 --- a/Tests/NTPIntegrationSpec.swift +++ b/Tests/TrueTimeTests/NTPIntegrationSpec.swift @@ -7,6 +7,7 @@ // @testable import TrueTime +import Foundation import Nimble import Quick