Returns the NSBundle instance that has the specified bundle identifier.


init?(identifier: String)



The identifier for an existing NSBundle instance.

Return Value

The NSBundle object with the bundle identifier identifier, or nil if the requested bundle is not found on the system.

This method creates and returns a new NSBundle object if there is no existing bundle associated with identifier. Otherwise, the existing instance is returned.


This method is typically used by frameworks and plug-ins to locate their own bundle at runtime. This method may be somewhat more efficient than trying to locate the bundle using the init(for:) method. However, if the initial lookup of an already loaded and cached bundle with the specified identifier fails, this method uses potentially time-consuming heuristics to attempt to locate the bundle. As an optimization, you can use the bundleWithPath: or bundleWithURL: method instead to avoid file system traversal.

See Also

Creating and Initializing a Bundle

init(for: AnyClass)

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

init?(url: URL)

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

init?(path: String)

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

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