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:
Jan ’26
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:
Replies
Boosts
Views
Activity
Jan ’26
Reply to Listing files of a background asset
I am also explicitly not using the contents(at:searchingInAssetPackWithID:options:) method, as this returns Data objects directly, which aren't useful in this case, as I need the actual file path to initialise these SQLite databases.
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Jan ’26
Reply to Background Assets - Apple Hosted - iOS26
Even though it is still not finding the asset pack, I worked around the fatal error by adding the following to my bundles entitlements: <key>com.apple.developer.team-identifier</key> <string>$(DEVELOPMENT_TEAM)</string>
Replies
Boosts
Views
Activity
Nov ’25
Reply to Background Assets - Apple Hosted - iOS26
The same is happening for me when trying to debug this on my Mac/SwiftUI app.
Replies
Boosts
Views
Activity
Nov ’25