Post

Replies

Boosts

Views

Activity

Reply to Listing files of a background asset
Thank you for this solution, this is way simpler than what I was trying to do. For anyone who wants this behaviour for themselves, I have put the solution above in a small reusable AssetPackManager extension: import System import BackgroundAssets @available(iOS 26, macOS 26, tvOS 26, *) @available(watchOS, unavailable) extension AssetPackManager { /// Performs a shallow search of the specified directory within all asset packs and returns the paths of any contained items. /// - Parameter path: The relative path to the asset pack directory whose contents you want to enumerate. /// - Returns: A list of `URL` objects, that identify the contents of this asset pack folder /// - Throws: When the path isn’t relative or when some other error occurs while retrieving the folder content. public nonisolated func contentsOfPack(atPath path: String) throws -> [URL] { let url = try AssetPackManager.shared.url(for: FilePath(stringLiteral: path)) let itemsInDirectory = try FileManager.default.contentsOfDirectory(atPath: url.path(percentEncoded: false)) var result: [URL] = [] result.reserveCapacity(itemsInDirectory.count) for itemName in itemsInDirectory { let fullURL = url.appending(component: itemName) result.append(fullURL) } return result } }
Topic: App & System Services SubTopic: General Tags:
2w