Skip to content

Commit 4914cc2

Browse files
authored
[Release Tooling] Only embed bundles containing privacy manifests (#12324)
1 parent b7d6209 commit 4914cc2

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

ReleaseTooling/Sources/ZipBuilder/FrameworkBuilder.swift

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,34 @@ struct FrameworkBuilder {
635635
"\(framework): \(error)")
636636
}
637637

638+
// Move any privacy manifest-containing resource bundles into the
639+
// platform framework.
640+
try? fileManager.contentsOfDirectory(
641+
at: frameworkPath.deletingLastPathComponent(),
642+
includingPropertiesForKeys: nil
643+
)
644+
.filter { $0.pathExtension == "bundle" }
645+
// TODO(ncooke3): Once the zip is built with Xcode 15, the following
646+
// `filter` can be removed. The following block exists to preserve
647+
// how resources (e.g. like FIAM's) are packaged for use in Xcode 14.
648+
.filter { bundleURL in
649+
let dirEnum = fileManager.enumerator(atPath: bundleURL.path)
650+
var containsPrivacyManifest = false
651+
while let relativeFilePath = dirEnum?.nextObject() as? String {
652+
if relativeFilePath.hasSuffix("PrivacyInfo.xcprivacy") {
653+
containsPrivacyManifest = true
654+
break
655+
}
656+
}
657+
return containsPrivacyManifest
658+
}
659+
// Bundles are moved rather than copied to prevent them from being
660+
// packaged in a `Resources` directory at the root of the xcframework.
661+
.forEach { try! fileManager.moveItem(
662+
at: $0,
663+
to: platformFrameworkDir.appendingPathComponent($0.lastPathComponent)
664+
) }
665+
638666
// Headers from slice
639667
do {
640668
let headersSrc: URL = frameworkPath.appendingPathComponent("Headers")

0 commit comments

Comments
 (0)