M-Swift All articles
Testing & Tooling

Paper Trail, Not Bug Hunt: Preflighting Privacy Manifests in Swift Dependencies

M-Swift
Paper Trail, Not Bug Hunt: Preflighting Privacy Manifests in Swift Dependencies

Photo: developer reviewing privacy manifest and Swift code on laptop with App Store Connect dashboard, via shuncy.com

Nothing ruins a Friday like an App Store Connect email that opens with a missing API declaration warning. You shipped a build, the tests passed, the screenshots looked good, and then the paperwork inside a third-party Swift package turned your release into a group chat.

The uncomfortable truth is that many 2026 App Store rejections are not code defects. They are declaration gaps. Your app calls UserDefaults, reads a file timestamp, or checks available disk space through some transitive dependency, and the privacy manifest does not say so. Apple's review pipeline sees the binary and the manifest; it does not care that the call site lives three packages deep.

So treat privacy manifests like build settings, not like legal documents you open once a year. The goal is a preflight audit you can run on every pull request, with a short checklist and a CI gate that makes undeclared API usage loud enough to fix before upload.

Start with the binary, not the bug tracker

Your own source is the easy part. The interesting surface area is .build/checkouts, the place where Swift Package Manager drops dependency source. That is where a helpful analytics SDK, a networking wrapper, or a persistence helper can introduce a required reason API without your team noticing.

The audit has three buckets:

The required reason APIs are the ones that produce the most avoidable warnings because they are boring. Nobody gets excited about NSPrivacyAccessedAPICategoryFileTimestamp until App Store Connect blocks the build.

A preflight checklist that fits in a PR

Run this before you archive:

Example manifest

Here is a minimal app-side manifest that declares UserDefaults usage. Keep it in the app target and let dependencies carry their own declarations.

<?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>NSPrivacyAccessedAPITypes</key>
  <array>
    <dict>
      <key>NSPrivacyAccessedAPIType</key>
      <string>NSPrivacyAccessedAPICategoryUserDefaults</string>
      <key>NSPrivacyAccessedAPITypeReasons</key>
      <array>
        <string>CA92.1</string>
      </array>
    </dict>
  </array>
  <key>NSPrivacyTracking</key>
  <false/>
  <key>NSPrivacyCollectedDataTypes</key>
  <array/>
</dict>
</plist>

That is not a complete privacy story for every app. It is the shape of the thing. The audit matters more than the sample because the sample will age out as your dependencies change.

A CI gate that fails loudly

This script is intentionally small. It scans dependency checkouts, looks for a handful of required reason API needles, and checks whether the matching category appears in that package's manifest. It is not a substitute for Apple's static analysis, but it catches the common case: a new package version starts using an API and nobody updates the paperwork.

#!/usr/bin/env bash
set -euo pipefail

CHECKOUTS=${1:-.build/checkouts}
FAIL=0

declare -A API_TO_CATEGORY=(
  ['NSUserDefaults']='NSPrivacyAccessedAPICategoryUserDefaults'
  ['attributesOfItem']='NSPrivacyAccessedAPICategoryFileTimestamp'
  ['systemUptime']='NSPrivacyAccessedAPICategorySystemBootTime'
  ['volumeAvailableCapacity']='NSPrivacyAccessedAPICategoryDiskSpace'
  ['activeInputModes']='NSPrivacyAccessedAPICategoryActiveKeyboards'
)

for pkg in $CHECKOUTS/*; do
  [ -d $pkg ] || continue
  manifest=$pkg/PrivacyInfo.xcprivacy
  for needle in ${!API_TO_CATEGORY[@]}; do
    category=${API_TO_CATEGORY[$needle]}
    if grep -R --include='*.swift' -q $needle $pkg; then
      if [ ! -f $manifest ] || ! grep -q $category $manifest; then
        printf '::error file=%s::Missing %s for %s\n' $pkg $category $needle
        FAIL=1
      fi
    fi
  done
done

exit $FAIL

Drop it into your CI after package resolution and before archive. If you use GitHub Actions, the ::error line gives you an inline annotation. If you use another CI provider, the exit code still stops the pipeline.

Expect false positives. A dependency may use NSUserDefaults only in a test target, or a string may appear in a comment. That is why the script is a tripwire, not a judge. Keep an allowlist with a reason and an owner, and make the allowlist expire. The worst outcome is a gate everyone disables because it cried wolf on a documentation string.

When a dependency is silent

If a package uses a required reason API and ships no manifest, you have three options: upgrade to a version that fixes it, vendor a patched copy with a manifest, or replace the dependency. Do not write a manifest for someone else's binary and assume it is accurate. You can declare what your app collects, but you cannot truthfully declare what a closed-source SDK does unless the vendor documents it.

This is also a good moment to check whether the dependency is doing more than you thought. A package that reads boot time for cache invalidation is one thing. A package that reads boot time and ships it to a server is a data collection question wearing an API declaration costume.

Ship the paperwork with the payload

The preflight is not glamorous. It will not make a demo video. But it turns a last-minute App Store Connect warning into a pull request annotation with a package path and a missing category. That is a much better Friday.

Run the scan, fix the manifest, keep the allowlist short, and archive with fewer surprises. The rejection is in the binary, but the fix belongs in your CI.

All Articles

Related Articles

Simulator Says Yes, iPhone Says Yikes: Seven Device-Only Swift Performance Tests

Simulator Says Yes, iPhone Says Yikes: Seven Device-Only Swift Performance Tests

Ten SwiftUI Accessibility Checks You Can Run Before Lunch

Ten SwiftUI Accessibility Checks You Can Run Before Lunch

I Migrated 50K Lines From XCTest to Swift Testing: The Wins, the Scars, and the Call I’d Make Today

I Migrated 50K Lines From XCTest to Swift Testing: The Wins, the Scars, and the Call I’d Make Today