BackgroundAssets `url(for:` throws error for locally available asset

On an iPhone running iOS 26 beta 5, url(for: FilePath("subdir/asset.mov")) most always throws this error:

The URL for “subdir/asset.mov” couldn’t be retrieved: “asset.mov” couldn’t be copied to “subdir” because an item with the same name already exists.

Yet, contents(at: FilePath("subdir/asset.mov")) always returns Data for a playable AVMovie.

How can I avoid this url(for:) error?

The asset pack in question is downloaded. The error persists even after pack deletion, redownload, relaunch, and combinations of that.

// Assets repo root
subdir.aar
subdir/asset.mov
subdir/asset_thumb.heic
subdir/Manifest.json
// Manifest.json
{
	"assetPackID": "subdir",
	"downloadPolicy": {
		"onDemand": {}
	},
	"fileSelectors": [
		{
			"directory": "subdir",
		},
	],
	"platforms": [
		"iOS",
		"visionOS"
	]
}
xcrun ba-package subdir/Manifest.json -o subdir.aar
xcrun ba-serve --host 192.168.0.10 -p 443 subdir.aar
Answered by Frameworks Engineer in 852899022

This looks like a bug on our side. Could you file a feedback report and reply to this thread with the feedback ID? Make sure to file the feedback report using the Feedback Assistant app on your development iPhone. Thanks!

A potential workaround is to pass just "subdir" to url(for:) and then to append "asset.mov" to the returned URL. url(for:) uses different logic for resolving directories compared to individual files, so until we have a fix available, you might be able to bypass the bug by triggering the directory-resolution logic instead of the file-resolution logic. Let me know if that works for you! (Note that this potential workaround is speculative at this point; we’ll need to look at a feedback report to confirm the underlying problem.)

Accepted Answer

This looks like a bug on our side. Could you file a feedback report and reply to this thread with the feedback ID? Make sure to file the feedback report using the Feedback Assistant app on your development iPhone. Thanks!

A potential workaround is to pass just "subdir" to url(for:) and then to append "asset.mov" to the returned URL. url(for:) uses different logic for resolving directories compared to individual files, so until we have a fix available, you might be able to bypass the bug by triggering the directory-resolution logic instead of the file-resolution logic. Let me know if that works for you! (Note that this potential workaround is speculative at this point; we’ll need to look at a feedback report to confirm the underlying problem.)

Filed FB19512759. If you're working up tests on the bug, I ought to detail the "almost always throws": on the very first access of a novel asset url(for:) does not throw.

Thanks for that workaround. Indeed, FileManager will enumerate and find assets and the manifest json.

One minor hitch: an asset that no longer exists in a pack will still exist in that directory (i.e., a previous pack version included it, that pack was locally deleted, and a new version of the pack without that asset was downloaded again).

BackgroundAssets `url(for:` throws error for locally available asset
 
 
Q