<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/URL/init(resource:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:10Foundation3URLV8resourceACSgAA11URLResourceV_tcfc"
  },
  "title" : "init(resource:)"
}
-->

# init(resource:)

Creates a URL from a resource.

```
init?(resource: URLResource)
```

## Parameters

`resource`

A [`URLResource`](/documentation/Foundation/URLResource) that provides a reference to a resource in a given bundle.

## Discussion

Use this initializer to resolve [`URLResource`](/documentation/Foundation/URLResource) instances, possibly received from other processes, into [`URL`](/documentation/Foundation/URL) instances.

---

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)