| Core Foundation | |
|---|---|
| Developer | Apple Inc. |
| Repository | github |
| Written in | Swift,Objective-C,C |
| Operating system | |
| Type | Systemlibrary |
| License | APSL 2.0 |
| Website | developer.apple.com |
Core Foundation (also calledCF) is aCapplication programming interface (API) written byApple Inc. for itsoperating systems, and is a mix of low-level routines andwrapper functions. Most Core Foundation routines follow a certain naming convention that deal with opaque objects, for example CFDictionaryRef for functions whose names begin with CFDictionary, and these objects are oftenreference counted (manually) throughCFRetain andCFRelease. Internally, Core Foundation forms the base of the types in theObjective-C standard library and theCarbon API.[1]
The most prevalent use of Core Foundation is for passing its own primitive types for data, including rawbytes,Unicodestrings,numbers,calendar dates, andUUIDs, as well as collections such asarrays,sets, anddictionaries, to numerous macOSC routines, primarily those that areGUI-related. At the operating system level Core Foundation also provides standardized application preferences management throughCFPropertyList,bundle handling,run loops,interprocess communication throughCFMachPort andCFNotificationCenter, and a basicgraphical user interface message dialog throughCFUserNotification.
Other parts of the API include utility routines and wrappers around existing APIs for ease of use. Utility routines perform such actions asfile system andnetworkI/O throughCFReadStream,CFWriteStream, andCFURL andendianness translation (Byte Order Utilities). Some examples of wrapper routines include those for Core Foundation's wrapper routines for Unix sockets, the CFSocket API.
Some types in Core Foundation are "toll-free bridged", or interchangeable with a simple cast, with those of theirFoundation Kit counterparts. For example, one could create aCFDictionaryRef Core Foundation type, and then later simply use a standard C cast to convert it to its Objective-C counterpart,NSDictionary *, and then use the desired Objective-C methods on that object as one normally would.
Core Foundation has a plug-in model (CFPlugin) that is based on theMicrosoftComponent Object Model.[2]
Apple used to release most of CF as anopen-source project called CFLite that can be used to write cross-platform applications for macOS,Linux, andWindows.[3]
A third-party open-source implementation called OpenCFLite extends the Apple CFLite for building on 32-bitWindows andLinux environments. It is maintained by one of theWebKit developers, but was stalled by 2015.[4] The karaoke platform KJams maintains a fork since 2017. This version, by its programmer David M. Cotter, supports 64-bit systems and has a CFNetwork implementation withLibreSSL-based TLS.[5] A fork of OpenCFLite was created by Grant Erickson (an original collaborator with Brent Fulgham on the SourceForge version) in 2021[6] with a companion port of theCFHost portion of CFNetwork, as OpenCFNetwork.[7]
The Swift Corelib Foundation, a fallback version of theFoundation Kit for the Swift programming language for non-Apple platforms, contains a near-full version of the Core Foundation released underApache License 2.0.[8]
GNUstep includes a version of the Core Foundation called "libs-corebase".[9]