diff --git a/CommonCrypto/module.modulemap b/CommonCrypto/module.modulemap deleted file mode 100644 index b70f7d6..0000000 --- a/CommonCrypto/module.modulemap +++ /dev/null @@ -1,4 +0,0 @@ -module CommonCrypto [system] { - header "shim.h" - export * -} diff --git a/CommonCrypto/shim.h b/CommonCrypto/shim.h deleted file mode 100644 index c332624..0000000 --- a/CommonCrypto/shim.h +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/Package.swift b/Package.swift index 5ba29b4..a6fe802 100644 --- a/Package.swift +++ b/Package.swift @@ -1,12 +1,10 @@ -// swift-tools-version:4.0 +// swift-tools-version:5.1 import PackageDescription #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) -let dependencies = [ - Package.Dependency.package(url: "https://github.com/kylef-archive/CommonCrypto.git", from: "1.0.0"), -] +let dependencies: [Package.Dependency] = [] let excludes = ["HMAC/HMACCryptoSwift.swift"] let targetDependencies: [Target.Dependency] = [] #else @@ -25,7 +23,11 @@ let package = Package( ], dependencies: dependencies, targets: [ - .target(name: "JWA", dependencies: targetDependencies, exclude: excludes), + .target(name: "JWA", + exclude: excludes, + linkerSettings: [ + .linkedFramework("CommonCrypto", .when(platforms: [.iOS, .macOS, .watchOS, .tvOS])), + ]), .target(name: "JWT", dependencies: ["JWA"]), .testTarget(name: "JWATests", dependencies: ["JWA"]), .testTarget(name: "JWTTests", dependencies: ["JWT"]), diff --git a/Sources/JWA/HMAC/HMACCommonCrypto.swift b/Sources/JWA/HMAC/HMACCommonCrypto.swift index 299fd8a..6dffce0 100644 --- a/Sources/JWA/HMAC/HMACCommonCrypto.swift +++ b/Sources/JWA/HMAC/HMACCommonCrypto.swift @@ -5,7 +5,7 @@ import CommonCrypto extension HMACAlgorithm: SignAlgorithm, VerifyAlgorithm { public func sign(_ message: Data) -> Data { let context = UnsafeMutablePointer.allocate(capacity: 1) - defer { context.deallocate(capacity: 1) } + defer { context.deallocate() } key.withUnsafeBytes() { (buffer: UnsafePointer) in CCHmacInit(context, hash.commonCryptoAlgorithm, buffer, size_t(key.count))