<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/Bundle/init(path:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSBundle(im)initWithPath:"
  },
  "title" : "init(path:)"
}
-->

# init(path:)

Returns an `NSBundle` object initialized to correspond to the specified directory.

```
init?(path: String)
```

## Parameters

`path`

The path to a directory. This must be a full pathname for a directory; if it contains any symbolic links, they must be resolvable.

## Return Value

An `NSBundle` object initialized to correspond to `fullPath`. This method initializes and returns a new instance only if there is no existing bundle associated with `fullPath`, otherwise it deallocates `self` and returns the existing object. If `fullPath` doesn’t exist or the user doesn’t have access to it, returns `nil`.

## Discussion

It’s not necessary to allocate and initialize an instance for the main bundle; use the [`main`](/documentation/Foundation/Bundle/main) class method to get this instance. You can also use the [`bundleWithPath:`](/documentation/Foundation/NSBundle/bundleWithPath:) class method to obtain a bundle identified by its directory path.

---

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)