@@ -57,6 +57,18 @@ if development {
57
57
]
58
58
}
59
59
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
+
60
72
let package = Package (
61
73
name: " swift-crypto " ,
62
74
platforms: [
@@ -76,7 +88,7 @@ let package = Package(
76
88
targets: [
77
89
. target(
78
90
name: " CCryptoBoringSSL " ,
79
- exclude: [
91
+ exclude: privacyManifestExclude + [
80
92
" hash.txt " ,
81
93
" include/boringssl_prefix_symbols_nasm.inc " ,
82
94
" CMakeLists.txt " ,
@@ -88,9 +100,7 @@ let package = Package(
88
100
" crypto/bio/socket_helper.c " ,
89
101
" crypto/bio/socket.c "
90
102
] ,
91
- resources: [
92
- . copy( " PrivacyInfo.xcprivacy " ) ,
93
- ] ,
103
+ resources: privacyManifestResource,
94
104
cSettings: [
95
105
// These defines come from BoringSSL's build system
96
106
. define( " _HAS_EXCEPTIONS " , to: " 0 " , . when( platforms: [ Platform . windows] ) ) ,
@@ -107,26 +117,22 @@ let package = Package(
107
117
. target(
108
118
name: " CCryptoBoringSSLShims " ,
109
119
dependencies: [ " CCryptoBoringSSL " ] ,
110
- exclude: [
120
+ exclude: privacyManifestExclude + [
111
121
" CMakeLists.txt "
112
122
] ,
113
- resources: [
114
- . copy( " PrivacyInfo.xcprivacy " ) ,
115
- ]
123
+ resources: privacyManifestResource
116
124
) ,
117
125
. target(
118
126
name: " Crypto " ,
119
127
dependencies: dependencies,
120
- exclude: [
128
+ exclude: privacyManifestExclude + [
121
129
" CMakeLists.txt " ,
122
130
" AEADs/Nonces.swift.gyb " ,
123
131
" Digests/Digests.swift.gyb " ,
124
132
" Key Agreement/ECDH.swift.gyb " ,
125
133
" Signatures/ECDSA.swift.gyb " ,
126
134
] ,
127
- resources: [
128
- . copy( " PrivacyInfo.xcprivacy " ) ,
129
- ] ,
135
+ resources: privacyManifestResource,
130
136
swiftSettings: swiftSettings + [ . define( " MODULE_IS_CRYPTO " ) ]
131
137
) ,
132
138
. target(
@@ -137,12 +143,10 @@ let package = Package(
137
143
" CryptoBoringWrapper " ,
138
144
" Crypto "
139
145
] ,
140
- exclude: [
146
+ exclude: privacyManifestExclude + [
141
147
" CMakeLists.txt " ,
142
148
] ,
143
- resources: [
144
- . copy( " PrivacyInfo.xcprivacy " ) ,
145
- ] ,
149
+ resources: privacyManifestResource,
146
150
swiftSettings: swiftSettings
147
151
) ,
148
152
. target(
@@ -151,12 +155,10 @@ let package = Package(
151
155
" CCryptoBoringSSL " ,
152
156
" CCryptoBoringSSLShims "
153
157
] ,
154
- exclude: [
158
+ exclude: privacyManifestExclude + [
155
159
" CMakeLists.txt " ,
156
160
] ,
157
- resources: [
158
- . copy( " PrivacyInfo.xcprivacy " ) ,
159
- ]
161
+ resources: privacyManifestResource
160
162
) ,
161
163
. executableTarget( name: " crypto-shasum " , dependencies: [ " Crypto " ] ) ,
162
164
. testTarget(
0 commit comments