What is the difference between Foundation, Darwin, and CoreFoundation?
The Foundation framework is an Obj-C framework part of Swift’s core libraries. It is the root of all NSObject types. Foundation is closed source.
The Core Foundation (CF) framework is a lower level C implemented library part of Swift’s core libraries. It is the root of all CF types. CF objects must have their memory managed manually. CF does not need a Obj-C runtime. CF is open source.
The difference between these two frameworks is mostly that CF has a very limited Object model (it is C based after all). On the backend, foundation and CF can convert between each other toll-free.
Darwin is a bridge to commonly used C functions. It is a superset of CoreFoundation & Foundation. Here is an example of how it might be used with compiler directives for system specific code:
|
|
There is also Swift standard library, which provides basic types like Strings.
Originally published 04/03/2021 @ https://pittcsc.org/ Discord
Published here on 09/08/2022. Blog published date reflects the original date of publication.