Search code examples
iosswiftswift-package-managerprivacy-manifest

Including privacy manifest in package.swift with binary target


I'm working on a 3rd party SDK (XCFramework) which is distributed a binary target via Swift Package Manager. Following last WWDC we need to include the privacy manifest as part of the package.

While there's a quick solution for "regular" targets by adding the file path to resources: [.process("Resources/PrivacyInfo.xcprivacy")], I couldn't find any example or straightforward solution for adding the .xcprivacy file for a binary target which currently offer this options:

static func binaryTarget(
    name: String,
    path: String
) -> Target
static func binaryTarget(
    name: String,
    url: String,
    checksum: String
) -> Target

Has anyone found a solution for it yet?


Solution

  • One way is to include the manifest in a wrapper target, like this grpc example:

        .target(
          name: "grpcppWrapper",
          dependencies: [
            "grpcpp",
          ],
          path: "grpcpp-Wrapper",
          resources: [.process("Resources/PrivacyInfo.xcprivacy")]
        ),
        .binaryTarget(
          name: "grpcpp",
          url: "https://dl.google.com/firebase/ios/bin/grpc/1.62.1/rc1/grpcpp.zip",
          checksum: "8075379cb5ab3fb84afca729e215b2503f20648e17d960a9fe013812156a42e0"
        ),