<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -",
    "macCatalyst: 26.0.0 -",
    "macOS: 26.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "BackgroundAssets",
  "identifier" : "/documentation/BackgroundAssets/AssetPackManager/url(for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Background Assets"
    ],
    "preciseIdentifier" : "s:16BackgroundAssets16AssetPackManagerC3url3for10Foundation3URLV6System8FilePathV_tKF"
  },
  "title" : "url(for:)"
}
-->

# url(for:)

Returns a URL for the specified relative path.

```
nonisolated func url(for path: FilePath) throws -> URL
```

## Parameters

`path`

The relative path.

## Return Value

The URL to the item.

## Discussion> Warning: Don’t persist the returned URL beyond the lifetime of the current process.

> Note: This method will return a well formed URL even if no item exists at the specified relative path in any asset pack, in which case any attempts to get its contents—whether it’s a file or a directory—will fail.

All asset packs share the same namespace, so you can treat the overall collection of downloaded asset packs as if it were a single root directory that contains all of your subdirectories and asset files, regardless of the specific asset pack in which any particular file resides. Unlike [`contents(at:searchingInAssetPackWithID:options:)`](/documentation/BackgroundAssets/AssetPackManager/contents(at:searchingInAssetPackWithID:options:)) and [`descriptor(for:searchingInAssetPackWithID:)`](/documentation/BackgroundAssets/AssetPackManager/descriptor(for:searchingInAssetPackWithID:)), this method supports retrieving entire directories—including packages—in which case it merges the corresponding slices of the shared logical directory from all downloaded asset packs that contain such slices. If there’s a path collision across multiple asset packs, then it’s undefined from which asset pack an individual file will be resolved.

> Warning: This method is less efficient than are ``doc://com.apple.backgroundassets/documentation/BackgroundAssets/AssetPackManager/contents(at:searchingInAssetPackWithID:options:)`` and ``doc://com.apple.backgroundassets/documentation/BackgroundAssets/AssetPackManager/descriptor(for:searchingInAssetPackWithID:)``; use those methods instead if you can do so. In particular, this method shouldn’t be used to get the URL to the root of the shared asset-pack namespace. Don’t use this method to block the main thread.

> Throws: When the path isn’t relative or when some other error occurs while finding the requested item.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)