Skip to content

Commit e463466

Browse files
authored
Fix metadata.md generation (#12423)
1 parent 3539c2b commit e463466

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

ReleaseTooling/Sources/Utils/FileManager+Utils.swift

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ public extension FileManager {
2828
/// All folders with a `.bundle` extension.
2929
case bundles
3030

31-
/// All folders with a `.bundle` extension excluding privacy manifest bundles.
32-
case nonPrivacyBundles
33-
3431
/// A directory with an optional name. If name is `nil`, all directories will be matched.
3532
case directories(name: String?)
3633

@@ -162,7 +159,13 @@ public extension FileManager {
162159
// Recursively search using the enumerator, adding any matches to the array.
163160
var matches: [URL] = []
164161
var foundXcframework = false // Ignore .frameworks after finding an xcframework.
165-
while let fileURL = dirEnumerator.nextObject() as? URL {
162+
for case let fileURL as URL in dirEnumerator {
163+
// Never mess with Privacy.bundles
164+
if fileURL.lastPathComponent.hasSuffix("_Privacy.bundle") {
165+
dirEnumerator.skipDescendants()
166+
continue
167+
}
168+
166169
switch type {
167170
case .allFiles:
168171
// Skip directories, include everything else.
@@ -189,13 +192,6 @@ public extension FileManager {
189192
if fileURL.pathExtension == "bundle" {
190193
matches.append(fileURL)
191194
}
192-
case .nonPrivacyBundles:
193-
// The only thing of interest is the path extension being ".bundle", but not a privacy
194-
// bundle.
195-
if fileURL.pathExtension == "bundle",
196-
!fileURL.lastPathComponent.hasSuffix("_Privacy.bundle") {
197-
matches.append(fileURL)
198-
}
199195
case .headers:
200196
if fileURL.pathExtension == "h" {
201197
matches.append(fileURL)

ReleaseTooling/Sources/ZipBuilder/ResourcesManager.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ extension ResourcesManager {
3030
static func directoryContainsResources(_ dir: URL) throws -> Bool {
3131
// First search for any .bundle files.
3232
let fileManager = FileManager.default
33-
let bundles = try fileManager.recursivelySearch(for: .nonPrivacyBundles, in: dir)
33+
let bundles = try fileManager.recursivelySearch(for: .bundles, in: dir)
3434

3535
// Stop searching if there were any bundles found.
3636
if !bundles.isEmpty { return true }
@@ -168,7 +168,7 @@ extension ResourcesManager {
168168
to resourceDir: URL,
169169
keepOriginal: Bool = false) throws -> [URL] {
170170
let fileManager = FileManager.default
171-
let allBundles = try fileManager.recursivelySearch(for: .nonPrivacyBundles, in: dir)
171+
let allBundles = try fileManager.recursivelySearch(for: .bundles, in: dir)
172172

173173
// If no bundles are found, return an empty array since nothing was done (but there wasn't an
174174
// error).

ReleaseTooling/Sources/ZipBuilder/ZipBuilder.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,11 @@ struct ZipBuilder {
243243
podInfo: podInfo)
244244
carthageGoogleUtilitiesFrameworks += cdFrameworks
245245
}
246-
if resourceContents != nil {
246+
let fileManager = FileManager.default
247+
if let resourceContents,
248+
let contents = try? fileManager.contentsOfDirectory(at: resourceContents,
249+
includingPropertiesForKeys: nil),
250+
!contents.isEmpty {
247251
resources[podName] = resourceContents
248252
}
249253
} else if podsBuilt[podName] == nil {

0 commit comments

Comments
 (0)