Skip to content

Commit 0717fc6

Browse files
author
Thomas Kalhøj Clemensen
committed
Removed unused imports and guarded CryptoKit import.
1 parent b1ce955 commit 0717fc6

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

Sources/TIMEncryptedStorage/Cryptors/AES/GCM.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import Foundation
2+
#if canImport(CryptoKit)
23
import CryptoKit
4+
#endif
35

46
extension TIMESCryptor.AES {
7+
#if canImport(CryptoKit)
58
@available(iOS 13, *)
69
struct GCM {
710
@available(iOS 13, *)
@@ -27,4 +30,20 @@ extension TIMESCryptor.AES {
2730
}
2831
}
2932
}
33+
#else
34+
// Dummy implementation. iOS 13 should always be able to import CryptoKit, but the archiving fails for Xcode 13+.
35+
// This way we can make the implementations available on compile time, to avoid build errors.
36+
@available(iOS 13, *)
37+
struct GCM {
38+
@available(iOS 13, *)
39+
static func encrypt(key: Data, data: Data) throws -> Data {
40+
fatalError("Failed to import CryptoKit!")
41+
}
42+
43+
@available(iOS 13, *)
44+
static func decrypt(key: Data, data: Data) throws -> Data {
45+
fatalError("Failed to import CryptoKit!")
46+
}
47+
}
48+
#endif
3049
}

Sources/TIMEncryptedStorage/Extensions/TIMKeyModel+Extensions.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import Foundation
2-
import CommonCrypto
3-
import CryptoKit
42

53
extension TIMKeyModel {
64

0 commit comments

Comments
 (0)