diff --git a/.DS_Store b/.DS_Store
new file mode 100644
index 0000000..cc7836c
Binary files /dev/null and b/.DS_Store differ
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.swift b/Package.swift
new file mode 100644
index 0000000..5138b33
--- /dev/null
+++ b/Package.swift
@@ -0,0 +1,32 @@
+// swift-tools-version:5.6
+import PackageDescription
+
+let package = Package(
+ name: "TrueTime",
+ platforms: [
+ .iOS(.v15), // iOS 10.0 이상 지원
+ ],
+ products: [
+ .library(
+ name: "TrueTime",
+ targets: ["TrueTime"]),
+ .library(
+ name: "CTrueTime",
+ targets: ["CTrueTime"]
+ )
+
+ ],
+ dependencies: [],
+
+ targets: [
+ .target(
+ name: "TrueTime",
+ dependencies: ["CTrueTime"],
+ path: "Sources/Swift"
+ ),
+ .systemLibrary(
+ name: "CTrueTime",
+ path: "Sources/CTrueTime"
+ )
+ ]
+)
diff --git a/Sources/Endian.swift b/Sources/Swift/Endian.swift
similarity index 99%
rename from Sources/Endian.swift
rename to Sources/Swift/Endian.swift
index 348fa59..c65c8e4 100644
--- a/Sources/Endian.swift
+++ b/Sources/Swift/Endian.swift
@@ -7,6 +7,7 @@
//
import Foundation
+import CTrueTime
protocol NetworkOrderConvertible {
var byteSwapped: Self { get }
diff --git a/Sources/GCDLock.swift b/Sources/Swift/GCDLock.swift
similarity index 100%
rename from Sources/GCDLock.swift
rename to Sources/Swift/GCDLock.swift
diff --git a/Sources/HostResolver.swift b/Sources/Swift/HostResolver.swift
similarity index 100%
rename from Sources/HostResolver.swift
rename to Sources/Swift/HostResolver.swift
diff --git a/Sources/NTPClient.swift b/Sources/Swift/NTPClient.swift
similarity index 99%
rename from Sources/NTPClient.swift
rename to Sources/Swift/NTPClient.swift
index e340749..77fa64e 100644
--- a/Sources/NTPClient.swift
+++ b/Sources/Swift/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/Swift/NTPConnection.swift
similarity index 99%
rename from Sources/NTPConnection.swift
rename to Sources/Swift/NTPConnection.swift
index 2606da3..7d02df0 100644
--- a/Sources/NTPConnection.swift
+++ b/Sources/Swift/NTPConnection.swift
@@ -7,6 +7,7 @@
//
import Foundation
+import CTrueTime
typealias NTPConnectionCallback = (NTPConnection, FrozenNetworkTimeResult) -> Void
diff --git a/Sources/NTPExtensions.swift b/Sources/Swift/NTPExtensions.swift
similarity index 98%
rename from Sources/NTPExtensions.swift
rename to Sources/Swift/NTPExtensions.swift
index c7d5088..e9a36dd 100644
--- a/Sources/NTPExtensions.swift
+++ b/Sources/Swift/NTPExtensions.swift
@@ -7,6 +7,7 @@
//
import Foundation
+import CTrueTime
public extension timeval {
static func uptime() -> timeval {
@@ -94,7 +95,7 @@ extension ByteRepresentable {
extension ntp_packet_t: ByteRepresentable {}
extension sockaddr_in: ByteRepresentable {}
extension sockaddr_in6: ByteRepresentable {}
-extension sockaddr_in6: CustomStringConvertible {
+extension sockaddr_in6: @retroactive CustomStringConvertible {
public var description: String {
var buffer = [Int8](repeating: 0, count: Int(INET6_ADDRSTRLEN))
var addr = sin6_addr
@@ -106,7 +107,7 @@ extension sockaddr_in6: CustomStringConvertible {
}
}
-extension sockaddr_in: CustomStringConvertible {
+extension sockaddr_in: @retroactive CustomStringConvertible {
public var description: String {
let host = String(cString: inet_ntoa(sin_addr))
let port = Int(sin_port)
diff --git a/Sources/NTPResponse.swift b/Sources/Swift/NTPResponse.swift
similarity index 99%
rename from Sources/NTPResponse.swift
rename to Sources/Swift/NTPResponse.swift
index b9bc6d9..c3b2f72 100644
--- a/Sources/NTPResponse.swift
+++ b/Sources/Swift/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/Swift/Reachability.swift
similarity index 100%
rename from Sources/Reachability.swift
rename to Sources/Swift/Reachability.swift
diff --git a/Sources/ReferenceTime.swift b/Sources/Swift/ReferenceTime.swift
similarity index 98%
rename from Sources/ReferenceTime.swift
rename to Sources/Swift/ReferenceTime.swift
index f187b25..bcd95bd 100644
--- a/Sources/ReferenceTime.swift
+++ b/Sources/Swift/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/Swift/SocketAddress.swift
similarity index 100%
rename from Sources/SocketAddress.swift
rename to Sources/Swift/SocketAddress.swift
diff --git a/Sources/TimedOperation.swift b/Sources/Swift/TimedOperation.swift
similarity index 96%
rename from Sources/TimedOperation.swift
rename to Sources/Swift/TimedOperation.swift
index 3ebcdf8..48d0f5a 100644
--- a/Sources/TimedOperation.swift
+++ b/Sources/Swift/TimedOperation.swift
@@ -8,7 +8,7 @@
import Foundation
-protocol TimedOperation: class {
+protocol TimedOperation: AnyObject {
var started: Bool { get }
var timeout: TimeInterval { get }
var timer: DispatchSourceTimer? { get set }
diff --git a/Sources/TrueTime.swift b/Sources/Swift/TrueTime.swift
similarity index 95%
rename from Sources/TrueTime.swift
rename to Sources/Swift/TrueTime.swift
index a588a4e..4a34490 100644
--- a/Sources/TrueTime.swift
+++ b/Sources/Swift/TrueTime.swift
@@ -8,6 +8,13 @@
import Foundation
+let TrueTimeErrorDomain = "com.instacart.TrueTimeErrorDomain"
+
+extension Notification.Name {
+ static let TrueTimeUpdated = Notification.Name.init("TrueTimeUpdatedNotification")
+}
+
+
@objc public enum TrueTimeError: Int {
case cannotFindHost
case dnsLookupFailed
@@ -117,9 +124,9 @@ extension TrueTimeClient {
@objc public func fetchIfNeeded(success: @escaping (ReferenceTime) -> Void,
failure: ((NSError) -> Void)?,
onQueue queue: DispatchQueue) {
- fetchIfNeeded(queue: queue) { result in
+ fetchIfNeeded(queue: queue, completion: { result in
self.mapBridgedResult(result, success: success, failure: failure)
- }
+ })
}
private func mapBridgedResult(_ result: ReferenceTimeResult,
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";