---
title: CFBundleGetMainBundle()
framework: corefoundation
role: symbol
role_heading: Function
path: corefoundation/cfbundlegetmainbundle()
---

# CFBundleGetMainBundle()

Returns an application’s main bundle.

## Declaration

```swift
func CFBundleGetMainBundle() -> CFBundle!
```

## Return Value

Return Value A CFBundle object representing the application’s main bundle, or NULL if it is not possible to create a bundle. Ownership follows the The Get Rule.

## Discussion

Discussion CFBundle creates a main bundle whenever it possibly can, even for unbundled apps. There are a few situations in which it is not possible, so you should check the return value against NULL, but this happens only in exceptional circumstances. For an explanation of the main bundle, see Locating and Opening Bundles in Bundle Programming Guide.

## See Also

### Creating and Accessing Bundles

- [CFBundleCreate(_:_:)](corefoundation/cfbundlecreate(_:_:).md)
- [CFBundleCreateBundlesFromDirectory(_:_:_:)](corefoundation/cfbundlecreatebundlesfromdirectory(_:_:_:).md)
- [CFBundleGetAllBundles()](corefoundation/cfbundlegetallbundles().md)
- [CFBundleGetBundleWithIdentifier(_:)](corefoundation/cfbundlegetbundlewithidentifier(_:).md)
