Skip to content

Commit 83a1500

Browse files
authored
Replace all Foundation imports with FoundationEssentials (#363)
### Motivation: FoundationEssentials produces smaller binaries on most platforms. ### Modifications: Where FoundationEssentials is available, import that. ### Result: Improved binary size
1 parent b5dde9c commit 83a1500

File tree

159 files changed

+742
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

159 files changed

+742
-3
lines changed

Benchmarks/Benchmarks/Benchmarks.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,14 @@
1313
//===----------------------------------------------------------------------===//
1414
import Benchmark
1515
import Crypto
16-
import Foundation
1716
import _CryptoExtras
1817

18+
#if canImport(FoundationEssentials)
19+
import FoundationEssentials
20+
#else
21+
import Foundation
22+
#endif
23+
1924
let benchmarks = {
2025
let defaultMetrics: [BenchmarkMetric] = [.mallocCountTotal, .cpuTotal]
2126

Sources/Crypto/AEADs/AES/GCM/AES-GCM.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,12 @@ typealias AESGCMImpl = OpenSSLAESGCMImpl
2525
#if CRYPTOKIT_NO_ACCESS_TO_FOUNDATION
2626
public import SwiftSystem
2727
#else
28+
#if canImport(FoundationEssentials)
29+
public import FoundationEssentials
30+
#else
2831
public import Foundation
2932
#endif
33+
#endif
3034

3135
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
3236
extension AES {

Sources/Crypto/AEADs/AES/GCM/BoringSSL/AES-GCM_boring.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@
1616
#else
1717
@_implementationOnly import CCryptoBoringSSL
1818
import CryptoBoringWrapper
19+
#if canImport(FoundationEssentials)
20+
import FoundationEssentials
21+
#else
1922
import Foundation
23+
#endif
2024

2125
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
2226
enum OpenSSLAESGCMImpl {

Sources/Crypto/AEADs/ChachaPoly/BoringSSL/ChaChaPoly_boring.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@
1717
@_implementationOnly import CCryptoBoringSSL
1818
@_implementationOnly import CCryptoBoringSSLShims
1919
import CryptoBoringWrapper
20+
#if canImport(FoundationEssentials)
21+
import FoundationEssentials
22+
#else
2023
import Foundation
24+
#endif
2125

2226
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
2327
extension BoringSSLAEAD {

Sources/Crypto/AEADs/ChachaPoly/ChaChaPoly.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,12 @@ typealias ChaChaPolyImpl = OpenSSLChaChaPolyImpl
2525
#if CRYPTOKIT_NO_ACCESS_TO_FOUNDATION
2626
public import SwiftSystem
2727
#else
28+
#if canImport(FoundationEssentials)
29+
public import FoundationEssentials
30+
#else
2831
public import Foundation
2932
#endif
33+
#endif
3034

3135

3236
/// An implementation of the ChaCha20-Poly1305 cipher.

Sources/Crypto/AEADs/Cipher.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@
1818
#if CRYPTOKIT_NO_ACCESS_TO_FOUNDATION
1919
import SwiftSystem
2020
#else
21+
#if canImport(FoundationEssentials)
22+
import FoundationEssentials
23+
#else
2124
import Foundation
2225
#endif
26+
#endif
2327

2428

2529
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)

Sources/Crypto/AEADs/Nonces.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,12 @@
1717
#if CRYPTOKIT_NO_ACCESS_TO_FOUNDATION
1818
public import SwiftSystem
1919
#else
20+
#if canImport(FoundationEssentials)
21+
public import FoundationEssentials
22+
#else
2023
public import Foundation
2124
#endif
25+
#endif
2226
// MARK: - Generated file, do NOT edit
2327
// any edits of this file WILL be overwritten and thus discarded
2428
// see section `gyb` in `README` for details.

Sources/Crypto/AEADs/Nonces.swift.gyb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,12 @@
1717
#if CRYPTOKIT_NO_ACCESS_TO_FOUNDATION
1818
public import SwiftSystem
1919
#else
20+
#if canImport(FoundationEssentials)
21+
public import FoundationEssentials
22+
#else
2023
public import Foundation
2124
#endif
25+
#endif
2226
// MARK: - Generated file, do NOT edit
2327
// any edits of this file WILL be overwritten and thus discarded
2428
// see section `gyb` in `README` for details.

Sources/Crypto/ASN1/ASN1.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@
1818
#if CRYPTOKIT_NO_ACCESS_TO_FOUNDATION
1919
import SwiftSystem
2020
#else
21+
#if canImport(FoundationEssentials)
22+
import FoundationEssentials
23+
#else
2124
import Foundation
2225
#endif
26+
#endif
2327

2428
// This module implements "just enough" ASN.1. Specifically, we implement exactly enough ASN.1 DER parsing to handle
2529
// the following use-cases:

Sources/Crypto/ASN1/Basic ASN1 Types/ASN1Any.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@
1818
#if CRYPTOKIT_NO_ACCESS_TO_FOUNDATION
1919
import SwiftSystem
2020
#else
21+
#if canImport(FoundationEssentials)
22+
import FoundationEssentials
23+
#else
2124
import Foundation
2225
#endif
26+
#endif
2327

2428
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
2529
extension ASN1 {

0 commit comments

Comments
 (0)