Skip to content

Commit

Permalink
Add privacy manifest (#2695)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
glbrntt committed Apr 17, 2024
1 parent 8b43f70 commit fa540cf
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
23 changes: 23 additions & 0 deletions .PrivacyInfo.xcprivacy
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPrivacyTracking</key>
<false/>
<key>NSPrivacyAccessedAPITypes</key>
<array>
<dict>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>0A2A.1</string>
</array>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
</dict>
</array>
<key>NSPrivacyCollectedDataTypes</key>
<array/>
<key>NSPrivacyTrackingDomains</key>
<array/>
</dict>
</plist>
12 changes: 11 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -83,7 +91,8 @@ let package = Package(
"NIOCore",
"_NIODataStructures",
swiftAtomics,
]
],
resources: includePrivacyManifest ? [.copy("PrivacyInfo.xcprivacy")] : []
),
.target(
name: "NIO",
Expand Down Expand Up @@ -199,6 +208,7 @@ let package = Package(
swiftSystem,
],
path: "Sources/NIOFileSystem",
resources: includePrivacyManifest ? [.copy("PrivacyInfo.xcprivacy")] : [],
swiftSettings: [
.define("ENABLE_MOCKING", .when(configuration: .debug))
]
Expand Down
1 change: 1 addition & 0 deletions Sources/NIOFileSystem/PrivacyInfo.xcprivacy
1 change: 1 addition & 0 deletions Sources/NIOPosix/PrivacyInfo.xcprivacy

0 comments on commit fa540cf

Please sign in to comment.