Skip to content

Commit a24950b

Browse files
authored
Only include privacy manifest on Darwin (#257)
Motivation: The privacy manifest is only required on Darwin. It's currently included on all platforms which results in build warnings. Modifications: - Only include manifest on Darwin - Exclude the privacy manifest from the build on other platforms Result: - Fewer warnings - Resolves #256
1 parent e8f2ddd commit a24950b

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

Package.swift

+22-20
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,18 @@ if development {
5757
]
5858
}
5959

60+
// This doesn't work when cross-compiling: the privacy manifest will be included in the Bundle and
61+
// Foundation will be linked. This is, however, strictly better than unconditionally adding the
62+
// resource.
63+
#if canImport(Darwin)
64+
let privacyManifestExclude: [String] = []
65+
let privacyManifestResource: [PackageDescription.Resource] = [.copy("PrivacyInfo.xcprivacy")]
66+
#else
67+
// Exclude on other platforms to avoid build warnings.
68+
let privacyManifestExclude: [String] = ["PrivacyInfo.xcprivacy"]
69+
let privacyManifestResource: [PackageDescription.Resource] = []
70+
#endif
71+
6072
let package = Package(
6173
name: "swift-crypto",
6274
platforms: [
@@ -76,7 +88,7 @@ let package = Package(
7688
targets: [
7789
.target(
7890
name: "CCryptoBoringSSL",
79-
exclude: [
91+
exclude: privacyManifestExclude + [
8092
"hash.txt",
8193
"include/boringssl_prefix_symbols_nasm.inc",
8294
"CMakeLists.txt",
@@ -88,9 +100,7 @@ let package = Package(
88100
"crypto/bio/socket_helper.c",
89101
"crypto/bio/socket.c"
90102
],
91-
resources: [
92-
.copy("PrivacyInfo.xcprivacy"),
93-
],
103+
resources: privacyManifestResource,
94104
cSettings: [
95105
// These defines come from BoringSSL's build system
96106
.define("_HAS_EXCEPTIONS", to: "0", .when(platforms: [Platform.windows])),
@@ -107,26 +117,22 @@ let package = Package(
107117
.target(
108118
name: "CCryptoBoringSSLShims",
109119
dependencies: ["CCryptoBoringSSL"],
110-
exclude: [
120+
exclude: privacyManifestExclude + [
111121
"CMakeLists.txt"
112122
],
113-
resources: [
114-
.copy("PrivacyInfo.xcprivacy"),
115-
]
123+
resources: privacyManifestResource
116124
),
117125
.target(
118126
name: "Crypto",
119127
dependencies: dependencies,
120-
exclude: [
128+
exclude: privacyManifestExclude + [
121129
"CMakeLists.txt",
122130
"AEADs/Nonces.swift.gyb",
123131
"Digests/Digests.swift.gyb",
124132
"Key Agreement/ECDH.swift.gyb",
125133
"Signatures/ECDSA.swift.gyb",
126134
],
127-
resources: [
128-
.copy("PrivacyInfo.xcprivacy"),
129-
],
135+
resources: privacyManifestResource,
130136
swiftSettings: swiftSettings + [.define("MODULE_IS_CRYPTO")]
131137
),
132138
.target(
@@ -137,12 +143,10 @@ let package = Package(
137143
"CryptoBoringWrapper",
138144
"Crypto"
139145
],
140-
exclude: [
146+
exclude: privacyManifestExclude + [
141147
"CMakeLists.txt",
142148
],
143-
resources: [
144-
.copy("PrivacyInfo.xcprivacy"),
145-
],
149+
resources: privacyManifestResource,
146150
swiftSettings: swiftSettings
147151
),
148152
.target(
@@ -151,12 +155,10 @@ let package = Package(
151155
"CCryptoBoringSSL",
152156
"CCryptoBoringSSLShims"
153157
],
154-
exclude: [
158+
exclude: privacyManifestExclude + [
155159
"CMakeLists.txt",
156160
],
157-
resources: [
158-
.copy("PrivacyInfo.xcprivacy"),
159-
]
161+
resources: privacyManifestResource
160162
),
161163
.executableTarget(name: "crypto-shasum", dependencies: ["Crypto"]),
162164
.testTarget(

0 commit comments

Comments
 (0)