Repository: firebase/firebase-ios-sdk (language: cpp)

Issue:
Binary Privacy Bundle structure has Resources directory inserted for macos and Catalyst
### Description

Solving this may eliminate the need for #12418

Investigation of the generated Metadata.md showed extra messages:

```
diff -r 10_20_0/Firebase/METADATA.md 10_22_0/Firebase/METADATA.md
17a18,20
> You'll also need to add the resources in the Resources
> directory into your target's main bundle.
> ...
```

Code inspection showed that gets added whenever there is a nested `Resources` directory.

```
./FirebaseAnalytics/GoogleUtilities.xcframework/ios-arm64_x86_64-maccatalyst/GoogleUtilities.framework/GoogleUtilities_Privacy.bundle
./FirebaseAnalytics/GoogleUtilities.xcframework/ios-arm64_x86_64-maccatalyst/GoogleUtilities.framework/GoogleUtilities_Privacy.bundle/Contents
./FirebaseAnalytics/GoogleUtilities.xcframework/ios-arm64_x86_64-maccatalyst/GoogleUtilities.framework/GoogleUtilities_Privacy.bundle/Contents/**Resources**
./FirebaseAnalytics/GoogleUtilities.xcframework/ios-arm64_x86_64-maccatalyst/GoogleUtilities.framework/GoogleUtilities_Privacy.bundle/Contents/**Resources**/PrivacyInfo.xcprivacy
./FirebaseAnalytics/GoogleUtilities.xcframework/ios-arm64_x86_64-maccatalyst/GoogleUtilities.framework/GoogleUtilities_Privacy.bundle/Contents/Info.plist
```

### Reproducing the issue

_No response_

### Firebase SDK Version

10.22-pre

### Xcode Version

15.3

### Installation Method

Zip

### Firebase Product(s)

Infrastructure

### Targeted Platforms

iOS

### Relevant Log Output

_No response_

### If using Swift Package Manager, the project's Package.resolved

<!--- Look below for instructions on how to share your Package.resolved. --->

<details>
<summary>Expand <code>Package.resolved</code> snippet</summary>
<br>

```json

Replace this line with the contents of your Package.resolved.

```

</details>


### If using CocoaPods, the project's Podfile.lock

<!--- Look below for instructions on how to share your Podfile.lock. --->

<details>
<summary>Expand <code>Podfile.lock</code> snippet</summary>
<br>

```yml

Replace this line with the contents of your Podfile.lock!

```

</details>



Discussion / hints:

Fix patch:
diff --git a/ReleaseTooling/Sources/Utils/FileManager+Utils.swift b/ReleaseTooling/Sources/Utils/FileManager+Utils.swift
index 1a657fd5155..5f25c4e5c83 100644
--- a/ReleaseTooling/Sources/Utils/FileManager+Utils.swift
+++ b/ReleaseTooling/Sources/Utils/FileManager+Utils.swift
@@ -28,9 +28,6 @@ public extension FileManager {
     /// All folders with a `.bundle` extension.
     case bundles
 
-    /// All folders with a `.bundle` extension excluding privacy manifest bundles.
-    case nonPrivacyBundles
-
     /// A directory with an optional name. If name is `nil`, all directories will be matched.
     case directories(name: String?)
 
@@ -162,7 +159,13 @@ public extension FileManager {
     // Recursively search using the enumerator, adding any matches to the array.
     var matches: [URL] = []
     var foundXcframework = false // Ignore .frameworks after finding an xcframework.
-    while let fileURL = dirEnumerator.nextObject() as? URL {
+    for case let fileURL as URL in dirEnumerator {
+      // Never mess with Privacy.bundles
+      if fileURL.lastPathComponent.hasSuffix("_Privacy.bundle") {
+        dirEnumerator.skipDescendants()
+        continue
+      }
+
       switch type {
       case .allFiles:
         // Skip directories, include everything else.
@@ -189,13 +192,6 @@ public extension FileManager {
         if fileURL.pathExtension == "bundle" {
           matches.append(fileURL)
         }
-      case .nonPrivacyBundles:
-        // The only thing of interest is the path extension being ".bundle", but not a privacy
-        // bundle.
-        if fileURL.pathExtension == "bundle",
-           !fileURL.lastPathComponent.hasSuffix("_Privacy.bundle") {
-          matches.append(fileURL)
-        }
       case .headers:
         if fileURL.pathExtension == "h" {
           matches.append(fileURL)
diff --git a/ReleaseTooling/Sources/ZipBuilder/ResourcesManager.swift b/ReleaseTooling/Sources/ZipBuilder/ResourcesManager.swift
index 48d1a964db8..fd2a6ad6a00 100644
--- a/ReleaseTooling/Sources/ZipBuilder/ResourcesManager.swift
+++ b/ReleaseTooling/Sources/ZipBuilder/ResourcesManager.swift
@@ -30,7 +30,7 @@ extension ResourcesManager {
   static func directoryContainsResources(_ dir: URL) throws -> Bool {
     // First search for any .bundle files.
     let fileManager = FileManager.default
-    let bundles = try fileManager.recursivelySearch(for: .nonPrivacyBundles, in: dir)
+    let bundles = try fileManager.recursivelySearch(for: .bundles, in: dir)
 
     // Stop searching if there were any bundles found.
     if !bundles.isEmpty { return true }
@@ -168,7 +168,7 @@ extension ResourcesManager {
                              to resourceDir: URL,
                              keepOriginal: Bool = false) throws -> [URL] {
     let fileManager = FileManager.default
-    let allBundles = try fileManager.recursivelySearch(for: .nonPrivacyBundles, in: dir)
+    let allBundles = try fileManager.recursivelySearch(for: .bundles, in: dir)
 
     // If no bundles are found, return an empty array since nothing was done (but there wasn't an
     // error).
diff --git a/ReleaseTooling/Sources/ZipBuilder/ZipBuilder.swift b/ReleaseTooling/Sources/ZipBuilder/ZipBuilder.swift
index aeca4a52dc5..ea46bd64085 100644
--- a/ReleaseTooling/Sources/ZipBuilder/ZipBuilder.swift
+++ b/ReleaseTooling/Sources/ZipBuilder/ZipBuilder.swift
@@ -243,7 +243,11 @@ struct ZipBuilder {
                                                                          podInfo: podInfo)
             carthageGoogleUtilitiesFrameworks += cdFrameworks
           }
-          if resourceContents != nil {
+          let fileManager = FileManager.default
+          if let resourceContents,
+             let contents = try? fileManager.contentsOfDirectory(at: resourceContents,
+                                                                 includingPropertiesForKeys: nil),
+             !contents.isEmpty {
             resources[podName] = resourceContents
           }
         } else if podsBuilt[podName] == nil {


Test patch: