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


init?(path: String)



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.


It’s not necessary to allocate and initialize an instance for the main bundle; use the main class method to get this instance. You can also use the bundleWithPath: class method to obtain a bundle identified by its directory path.

See Also

Creating and Initializing a Bundle

init(for: AnyClass)

Returns the NSBundle object with which the specified class is associated.

init?(identifier: String)

Returns the NSBundle instance that has the specified bundle identifier.

init?(url: URL)

Returns an NSBundle object initialized to correspond to the specified file URL.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software