From fa540cf39b0f9a049a2ac06bccb20b6681d1b29a Mon Sep 17 00:00:00 2001 From: George Barnett Date: Wed, 17 Apr 2024 10:48:03 +0100 Subject: [PATCH] Add privacy manifest (#2695) Motivation: NIOPosix and NIOFileSystem use stat(2) (or some variation of it). These are "required reason APIs" meaning that their usage and reason must be declared in a privacy manifest in order to be submitted to the App Store. Modifications: - Add a privacy manifest to NIOPosix and NIOFileSystem Result: Apps using NIO won't be rejected from App Store submission for missing privacy manifests. --- .PrivacyInfo.xcprivacy | 23 +++++++++++++++++++++ Package.swift | 12 ++++++++++- Sources/NIOFileSystem/PrivacyInfo.xcprivacy | 1 + Sources/NIOPosix/PrivacyInfo.xcprivacy | 1 + 4 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 .PrivacyInfo.xcprivacy create mode 120000 Sources/NIOFileSystem/PrivacyInfo.xcprivacy create mode 120000 Sources/NIOPosix/PrivacyInfo.xcprivacy diff --git a/.PrivacyInfo.xcprivacy b/.PrivacyInfo.xcprivacy new file mode 100644 index 0000000000..77e64b8e62 --- /dev/null +++ b/.PrivacyInfo.xcprivacy @@ -0,0 +1,23 @@ + + + + + NSPrivacyTracking + + NSPrivacyAccessedAPITypes + + + NSPrivacyAccessedAPITypeReasons + + 0A2A.1 + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategoryFileTimestamp + + + NSPrivacyCollectedDataTypes + + NSPrivacyTrackingDomains + + + diff --git a/Package.swift b/Package.swift index 9d732d1965..56c07a97e4 100644 --- a/Package.swift +++ b/Package.swift @@ -23,6 +23,14 @@ let swiftSystem: PackageDescription.Target.Dependency = .product( condition: .when(platforms: [.macOS, .iOS, .tvOS, .watchOS, .linux, .android]) ) +// This doesn't work when cross-compiling: the privacy manifest will be included in the Bundle and +// Foundation will be linked. This is, however, strictly better than unconditionally adding the +// resource. +#if canImport(Darwin) +let includePrivacyManifest = true +#else +let includePrivacyManifest = false +#endif let package = Package( name: "swift-nio", @@ -83,7 +91,8 @@ let package = Package( "NIOCore", "_NIODataStructures", swiftAtomics, - ] + ], + resources: includePrivacyManifest ? [.copy("PrivacyInfo.xcprivacy")] : [] ), .target( name: "NIO", @@ -199,6 +208,7 @@ let package = Package( swiftSystem, ], path: "Sources/NIOFileSystem", + resources: includePrivacyManifest ? [.copy("PrivacyInfo.xcprivacy")] : [], swiftSettings: [ .define("ENABLE_MOCKING", .when(configuration: .debug)) ] diff --git a/Sources/NIOFileSystem/PrivacyInfo.xcprivacy b/Sources/NIOFileSystem/PrivacyInfo.xcprivacy new file mode 120000 index 0000000000..11b855aa14 --- /dev/null +++ b/Sources/NIOFileSystem/PrivacyInfo.xcprivacy @@ -0,0 +1 @@ +../../.PrivacyInfo.xcprivacy \ No newline at end of file diff --git a/Sources/NIOPosix/PrivacyInfo.xcprivacy b/Sources/NIOPosix/PrivacyInfo.xcprivacy new file mode 120000 index 0000000000..11b855aa14 --- /dev/null +++ b/Sources/NIOPosix/PrivacyInfo.xcprivacy @@ -0,0 +1 @@ +../../.PrivacyInfo.xcprivacy \ No newline at end of file