Contents

main

Returns the bundle object that contains the current executable.

Declaration

class var main: Bundle { get }

Return Value

The NSBundle object corresponding to the bundle directory that contains the current executable. This method may return a valid bundle object even for unbundled apps. It may also return nil if the bundle object could not be created, so always check the return value.

Discussion

The main bundle lets you access the resources in the same directory as the currently running executable. For a running app or code running in a framework, the main bundle offers access to the app’s bundle directory.

See Also

Related Documentation

  • Resource Programming Guide
  • init(for:)
  • Bundle Programming Guide

Getting Standard Bundle Objects