From 4914cc295e41427025ebf32c7bba86b839a876eb Mon Sep 17 00:00:00 2001 From: Nick Cooke <36927374+ncooke3@users.noreply.github.com> Date: Sat, 27 Jan 2024 19:24:29 -0500 Subject: [PATCH] [Release Tooling] Only embed bundles containing privacy manifests (#12324) --- .../Sources/ZipBuilder/FrameworkBuilder.swift | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/ReleaseTooling/Sources/ZipBuilder/FrameworkBuilder.swift b/ReleaseTooling/Sources/ZipBuilder/FrameworkBuilder.swift index 8f6f8f2fbbe..3f4e7172e9a 100755 --- a/ReleaseTooling/Sources/ZipBuilder/FrameworkBuilder.swift +++ b/ReleaseTooling/Sources/ZipBuilder/FrameworkBuilder.swift @@ -635,6 +635,34 @@ struct FrameworkBuilder { "\(framework): \(error)") } + // Move any privacy manifest-containing resource bundles into the + // platform framework. + try? fileManager.contentsOfDirectory( + at: frameworkPath.deletingLastPathComponent(), + includingPropertiesForKeys: nil + ) + .filter { $0.pathExtension == "bundle" } + // TODO(ncooke3): Once the zip is built with Xcode 15, the following + // `filter` can be removed. The following block exists to preserve + // how resources (e.g. like FIAM's) are packaged for use in Xcode 14. + .filter { bundleURL in + let dirEnum = fileManager.enumerator(atPath: bundleURL.path) + var containsPrivacyManifest = false + while let relativeFilePath = dirEnum?.nextObject() as? String { + if relativeFilePath.hasSuffix("PrivacyInfo.xcprivacy") { + containsPrivacyManifest = true + break + } + } + return containsPrivacyManifest + } + // Bundles are moved rather than copied to prevent them from being + // packaged in a `Resources` directory at the root of the xcframework. + .forEach { try! fileManager.moveItem( + at: $0, + to: platformFrameworkDir.appendingPathComponent($0.lastPathComponent) + ) } + // Headers from slice do { let headersSrc: URL = frameworkPath.appendingPathComponent("Headers")