<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreFoundation",
  "identifier" : "/documentation/CoreFoundation/CFBundle",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Core Foundation"
    ],
    "preciseIdentifier" : "c:@T@CFBundleRef"
  },
  "title" : "CFBundle"
}
-->

# CFBundle

```
class CFBundle
```

## Overview

CFBundle allows you to use a folder hierarchy called a bundle to organize and locate many types of application resources including images, sounds, localized strings, and executable code. In macOS, bundles can also be used by CFM applications to load and execute functions from Mach-O frameworks. You can use bundles to support multiple languages or execute your application on multiple operating environments.

You create a bundle object using one of the `CFBundleCreate...` functions. CFBundle provides several functions for finding resources within a bundle. The [`CFBundleCopyResourceURL(_:_:_:_:)`](/documentation/CoreFoundation/CFBundleCopyResourceURL(_:_:_:_:)) function returns the location of a resource of the specified name and type, and in the specified subdirectory. Use [`CFBundleCopyResourceURLForLocalization(_:_:_:_:_:)`](/documentation/CoreFoundation/CFBundleCopyResourceURLForLocalization(_:_:_:_:_:)) to restrict the search to a specific localization name. Use [`CFBundleCopyResourceURLsOfType(_:_:_:)`](/documentation/CoreFoundation/CFBundleCopyResourceURLsOfType(_:_:_:)) to get the locations of all resources of a specified type.

CFBundle provides functions for getting bundle information, such as its identifier and information dictionary. Use the [`CFBundleGetIdentifier(_:)`](/documentation/CoreFoundation/CFBundleGetIdentifier(_:)) function to get the identifier of a bundle, and the [`CFBundleGetInfoDictionary(_:)`](/documentation/CoreFoundation/CFBundleGetInfoDictionary(_:)) function to get its information dictionary. The principal intended purpose for locating bundles by identifier is so that code (in frameworks, plugins, etc.) can find its own bundle.

You can also obtain locations of subdirectories in a bundle represented as CFURL objects. The [`CFBundleCopyExecutableURL(_:)`](/documentation/CoreFoundation/CFBundleCopyExecutableURL(_:)) function returns the location of the application’s executable. The functions [`CFBundleCopyResourceURL(_:_:_:_:)`](/documentation/CoreFoundation/CFBundleCopyResourceURL(_:_:_:_:)), [`CFBundleCopySharedFrameworksURL(_:)`](/documentation/CoreFoundation/CFBundleCopySharedFrameworksURL(_:)), [`CFBundleCopyPrivateFrameworksURL(_:)`](/documentation/CoreFoundation/CFBundleCopyPrivateFrameworksURL(_:)), [`CFBundleCopySharedSupportURL(_:)`](/documentation/CoreFoundation/CFBundleCopySharedSupportURL(_:)), and [`CFBundleCopyBuiltInPlugInsURL(_:)`](/documentation/CoreFoundation/CFBundleCopyBuiltInPlugInsURL(_:)) return the location of a bundle’s subdirectory containing resources, shared frameworks, private frameworks, shared support files, and plug-ins respectively.

Other functions are used to manage localizations. The [`CFBundleCopyLocalizedString(_:_:_:_:)`](/documentation/CoreFoundation/CFBundleCopyLocalizedString(_:_:_:_:)) and [`CFBundleCopyLocalizationsForURL(_:)`](/documentation/CoreFoundation/CFBundleCopyLocalizationsForURL(_:)) functions return a localized string from a bundle’s strings file. The [`CFBundleCopyLocalizationsForPreferences(_:_:)`](/documentation/CoreFoundation/CFBundleCopyLocalizationsForPreferences(_:_:)) function returns the localizations that CFBundle would prefer, given the specified bundle and user preference localizations.

Unlike some other Core Foundation opaque types with similar Cocoa Foundation names (such as CFString and `NSString`), <doc://com.apple.documentation/documentation/Foundation/Bundle> objects cannot be cast (“toll-free bridged”) to CFBundle objects.

Unlike `NSBundle`, which does not support unloading (because the Objective C runtime does not support the unloading of Objective C code), you can unload CFBundle objects.

[`CFBundleGetFunctionPointerForName(_:_:)`](/documentation/CoreFoundation/CFBundleGetFunctionPointerForName(_:_:)) and related calls automatically load a bundle if it is not already loaded. When the last reference to the CFBundle object is released and it is finally deallocated, then the code will be unloaded if it is still loaded and if the executable is of a type that supports unloading. If you keep this in mind, and if you make sure that everything that uses the bundle keeps a retain on the CFBundle object, then you can just use the bundle naturally and never have to worry about when it is loaded and unloaded.

On the other hand, if you want to manually manage when the bundle is loaded and unloaded, then you can use [`CFBundleLoadExecutable(_:)`](/documentation/CoreFoundation/CFBundleLoadExecutable(_:)) and [`CFBundleUnloadExecutable(_:)`](/documentation/CoreFoundation/CFBundleUnloadExecutable(_:))—although this technique is not recommended. These functions force immediate loading and unloading of the executable (if it has not already been loaded/unloaded, and in the case of unloading if the executable is of a type that supports unloading). If you do this, then the code calling `CFBundleUnloadExecutable` is responsible for making sure that there are no remaining references to anything in the bundle’s code before it is unloaded. In the previous approach, by contrast, this responsibility can be distributed to the individual code sections that use the bundle, by making sure that each one keeps its own retain on the CFBundle object.

One further point about CFBundle reference counting: if you are taking the first approach, but do not actually wish the bundle’s code to be unloaded (as is often the case), or if you are taking the second approach of manually managing the unloading yourself, then in many cases you do not actually have to worry about releasing a CFBundle object. CFBundle instances are uniqued, so there is only one CFBundle object for a given bundle, and rarely are there so many bundles being considered at once that the memory usage for CFBundle objects would be significant. There are cases in which a process could create CFBundle objects for potentially an unlimited number of bundles, and such processes would wish to balance retains and releases carefully, but such cases are likely to be rare.

Note that it is best to compile any unloadable bundles with the flag `-fno-constant-cfstrings`—see [Bundle Programming Guide](https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFBundles/Introduction/Introduction.html#//apple_ref/doc/uid/10000123i) for more details.

## Topics

### Creating and Accessing Bundles

[`CFBundleCreate(_:_:)`](/documentation/CoreFoundation/CFBundleCreate(_:_:))

Creates a CFBundle object.

[`CFBundleCreateBundlesFromDirectory(_:_:_:)`](/documentation/CoreFoundation/CFBundleCreateBundlesFromDirectory(_:_:_:))

Searches a directory and constructs an array of CFBundle objects from all valid bundles in the specified directory.

[`CFBundleGetAllBundles()`](/documentation/CoreFoundation/CFBundleGetAllBundles())

Returns an array containing all of the bundles currently open in the application.

[`CFBundleGetBundleWithIdentifier(_:)`](/documentation/CoreFoundation/CFBundleGetBundleWithIdentifier(_:))

Locate a bundle given its program-defined identifier.

[`CFBundleGetMainBundle()`](/documentation/CoreFoundation/CFBundleGetMainBundle())

Returns an application’s main bundle.

### Loading and Unloading a Bundle

[`CFBundleIsExecutableLoaded(_:)`](/documentation/CoreFoundation/CFBundleIsExecutableLoaded(_:))

Obtains information about the load status for a bundle’s main executable.

[`CFBundlePreflightExecutable(_:_:)`](/documentation/CoreFoundation/CFBundlePreflightExecutable(_:_:))

Returns a Boolean value that indicates whether a given bundle is loaded or appears to be loadable.

[`CFBundleLoadExecutable(_:)`](/documentation/CoreFoundation/CFBundleLoadExecutable(_:))

Loads a bundle’s main executable code into memory and dynamically links it into the running application.

[`CFBundleLoadExecutableAndReturnError(_:_:)`](/documentation/CoreFoundation/CFBundleLoadExecutableAndReturnError(_:_:))

Returns a Boolean value that indicates whether a given bundle is loaded, attempting to load it if necessary.

[`CFBundleUnloadExecutable(_:)`](/documentation/CoreFoundation/CFBundleUnloadExecutable(_:))

Unloads the main executable for the specified bundle.

### Finding Locations in a Bundle

[`CFBundleCopyAuxiliaryExecutableURL(_:_:)`](/documentation/CoreFoundation/CFBundleCopyAuxiliaryExecutableURL(_:_:))

Returns the location of a bundle’s auxiliary executable code.

[`CFBundleCopyBuiltInPlugInsURL(_:)`](/documentation/CoreFoundation/CFBundleCopyBuiltInPlugInsURL(_:))

Returns the location of a bundle’s built in plug-in.

[`CFBundleCopyExecutableURL(_:)`](/documentation/CoreFoundation/CFBundleCopyExecutableURL(_:))

Returns the location of a bundle’s main executable code.

[`CFBundleCopyPrivateFrameworksURL(_:)`](/documentation/CoreFoundation/CFBundleCopyPrivateFrameworksURL(_:))

Returns the location of a bundle’s private Frameworks directory.

[`CFBundleCopyResourcesDirectoryURL(_:)`](/documentation/CoreFoundation/CFBundleCopyResourcesDirectoryURL(_:))

Returns the location of a bundle’s Resources directory.

[`CFBundleCopySharedFrameworksURL(_:)`](/documentation/CoreFoundation/CFBundleCopySharedFrameworksURL(_:))

Returns the location of a bundle’s shared frameworks directory.

[`CFBundleCopySharedSupportURL(_:)`](/documentation/CoreFoundation/CFBundleCopySharedSupportURL(_:))

Returns the location of a bundle’s shared support files directory.

[`CFBundleCopySupportFilesDirectoryURL(_:)`](/documentation/CoreFoundation/CFBundleCopySupportFilesDirectoryURL(_:))

Returns the location of the bundle’s support files directory.

### Locating Bundle Resources

[`CFBundleCloseBundleResourceMap(_:_:)`](/documentation/CoreFoundation/CFBundleCloseBundleResourceMap(_:_:))

Closes an open resource map for a bundle.

[`CFBundleCopyResourceURL(_:_:_:_:)`](/documentation/CoreFoundation/CFBundleCopyResourceURL(_:_:_:_:))

Returns the location of a resource contained in the specified bundle.

[`CFBundleCopyResourceURLInDirectory(_:_:_:_:)`](/documentation/CoreFoundation/CFBundleCopyResourceURLInDirectory(_:_:_:_:))

Returns the location of a resource contained in the specified bundle directory without requiring the creation of a CFBundle object.

[`CFBundleCopyResourceURLsOfType(_:_:_:)`](/documentation/CoreFoundation/CFBundleCopyResourceURLsOfType(_:_:_:))

Assembles an array of URLs specifying all of the resources of the specified type found in a bundle.

[`CFBundleCopyResourceURLsOfTypeInDirectory(_:_:_:)`](/documentation/CoreFoundation/CFBundleCopyResourceURLsOfTypeInDirectory(_:_:_:))

Returns an array of CFURL objects describing the locations of all resources in a bundle of the specified type without needing to create a CFBundle object.

[`CFBundleCopyResourceURLForLocalization(_:_:_:_:_:)`](/documentation/CoreFoundation/CFBundleCopyResourceURLForLocalization(_:_:_:_:_:))

Returns the location of a localized resource in a bundle.

[`CFBundleCopyResourceURLsOfTypeForLocalization(_:_:_:_:)`](/documentation/CoreFoundation/CFBundleCopyResourceURLsOfTypeForLocalization(_:_:_:_:))

Returns an array containing copies of the URL locations for a specified bundle, resource, and localization name.

[`CFBundleOpenBundleResourceFiles(_:_:_:)`](/documentation/CoreFoundation/CFBundleOpenBundleResourceFiles(_:_:_:))

Opens the non-localized and localized resource files (if any) for a bundle in separate resource maps.

[`CFBundleOpenBundleResourceMap(_:)`](/documentation/CoreFoundation/CFBundleOpenBundleResourceMap(_:))

Opens the non-localized and localized resource files (if any) for a bundle in a single resource map.

### Managing Localizations

[`CFBundleCopyBundleLocalizations(_:)`](/documentation/CoreFoundation/CFBundleCopyBundleLocalizations(_:))

Returns an array containing a bundle’s localizations.

[`CFBundleCopyLocalizedString(_:_:_:_:)`](/documentation/CoreFoundation/CFBundleCopyLocalizedString(_:_:_:_:))

Returns a localized string from a bundle’s strings file.

[`CFBundleCopyLocalizationsForPreferences(_:_:)`](/documentation/CoreFoundation/CFBundleCopyLocalizationsForPreferences(_:_:))

Given an array of possible localizations and preferred locations, returns the one or more of them that CFBundle would use, without reference to the current application context.

[`CFBundleCopyLocalizationsForURL(_:)`](/documentation/CoreFoundation/CFBundleCopyLocalizationsForURL(_:))

Returns an array containing the localizations for a bundle or executable at a particular location.

[`CFBundleCopyPreferredLocalizationsFromArray(_:)`](/documentation/CoreFoundation/CFBundleCopyPreferredLocalizationsFromArray(_:))

Given an array of possible localizations, returns the one or more of them that CFBundle would use in the current application context.

[`CFCopyLocalizedString`](/documentation/CoreFoundation/CFCopyLocalizedString)

Searches the default strings file `Localizable.strings` for the string associated with the specified key.

[`CFCopyLocalizedStringFromTable`](/documentation/CoreFoundation/CFCopyLocalizedStringFromTable)

Searches the specified strings file for the string associated with the specified key.

[`CFCopyLocalizedStringFromTableInBundle`](/documentation/CoreFoundation/CFCopyLocalizedStringFromTableInBundle)

Returns a localized version of the specified string.

[`CFCopyLocalizedStringWithDefaultValue`](/documentation/CoreFoundation/CFCopyLocalizedStringWithDefaultValue)

Returns a localized version of a localization string.

### Managing Executable Code

[`CFBundleGetDataPointerForName(_:_:)`](/documentation/CoreFoundation/CFBundleGetDataPointerForName(_:_:))

Returns a data pointer to a symbol of the given name.

[`CFBundleGetDataPointersForNames(_:_:_:)`](/documentation/CoreFoundation/CFBundleGetDataPointersForNames(_:_:_:))

Returns a C array of data pointer to symbols of the given names.

[`CFBundleGetFunctionPointerForName(_:_:)`](/documentation/CoreFoundation/CFBundleGetFunctionPointerForName(_:_:))

Returns a pointer to a function in a bundle’s executable code using the function name as the search key.

[`CFBundleGetFunctionPointersForNames(_:_:_:)`](/documentation/CoreFoundation/CFBundleGetFunctionPointersForNames(_:_:_:))

Constructs a function table containing pointers to all of the functions found in a bundle’s main executable code.

[`CFBundleGetPlugIn(_:)`](/documentation/CoreFoundation/CFBundleGetPlugIn(_:))

Returns a bundle’s plug-in.

### Getting Bundle Properties

[`CFBundleCopyBundleURL(_:)`](/documentation/CoreFoundation/CFBundleCopyBundleURL(_:))

Returns the location of a bundle.

[`CFBundleGetDevelopmentRegion(_:)`](/documentation/CoreFoundation/CFBundleGetDevelopmentRegion(_:))

Returns the bundle’s development region from the bundle’s information property list.

[`CFBundleGetIdentifier(_:)`](/documentation/CoreFoundation/CFBundleGetIdentifier(_:))

Returns the bundle identifier from a bundle’s information property list.

[`CFBundleGetInfoDictionary(_:)`](/documentation/CoreFoundation/CFBundleGetInfoDictionary(_:))

Returns a bundle’s information dictionary.

[`CFBundleGetLocalInfoDictionary(_:)`](/documentation/CoreFoundation/CFBundleGetLocalInfoDictionary(_:))

Returns a bundle’s localized information dictionary.

[`CFBundleGetValueForInfoDictionaryKey(_:_:)`](/documentation/CoreFoundation/CFBundleGetValueForInfoDictionaryKey(_:_:))

Returns a value (localized if possible) from a bundle’s information dictionary.

[`CFBundleCopyInfoDictionaryInDirectory(_:)`](/documentation/CoreFoundation/CFBundleCopyInfoDictionaryInDirectory(_:))

Returns a bundle’s information dictionary.

[`CFBundleCopyInfoDictionaryForURL(_:)`](/documentation/CoreFoundation/CFBundleCopyInfoDictionaryForURL(_:))

Returns the information dictionary for a given URL location.

[`CFBundleGetPackageInfo(_:_:_:)`](/documentation/CoreFoundation/CFBundleGetPackageInfo(_:_:_:))

Returns a bundle’s package type and creator.

[`CFBundleGetPackageInfoInDirectory(_:_:_:)`](/documentation/CoreFoundation/CFBundleGetPackageInfoInDirectory(_:_:_:))

Returns a bundle’s package type and creator without having to create a CFBundle object.

[`CFBundleCopyExecutableArchitectures(_:)`](/documentation/CoreFoundation/CFBundleCopyExecutableArchitectures(_:))

Returns an array of CFNumbers representing the architectures a given bundle provides.

[`CFBundleCopyExecutableArchitecturesForURL(_:)`](/documentation/CoreFoundation/CFBundleCopyExecutableArchitecturesForURL(_:))

Returns an array of CFNumbers representing the architectures a given URL provides.

[`CFBundleGetVersionNumber(_:)`](/documentation/CoreFoundation/CFBundleGetVersionNumber(_:))

Returns a bundle’s version number.

### Getting the CFBundle Type ID

[`CFBundleGetTypeID()`](/documentation/CoreFoundation/CFBundleGetTypeID())

Returns the type identifier for the CFBundle opaque type.

### Data Types

[`CFBundleRefNum`](/documentation/CoreFoundation/CFBundleRefNum)

Type that identifies a distinct reference number for a resource map.

### Constants

[Information Property List Keys](/documentation/CoreFoundation/information-property-list-keys)

Standard keys found in a bundle’s information property list file.

[Architecture Types](/documentation/CoreFoundation/1537096-architecture-types)

Constants that identify executable architecture types.

## See Also

  [Bundle Programming Guide](https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFBundles/Introduction/Introduction.html#//apple_ref/doc/uid/10000123i)



---

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)