Changes to Foundation must go through swift-evolution

Hi all,

Thanks for starting this discussion. I think it gives us a great opportunity to bring more clarity to our process. Let's start with a clear definition of the projects we're talking about here.

Foundation

Foundation is a framework and Swift "overlay" that ships with each version of macOS, iOS, watchOS, and tvOS (sometimes collectively referred to as "Darwin"). It is closed source, written in a variety of languages (C, Objective-C, and Swift), and uses an Apple-internal process for evolution of its API and functionality. The goal of Foundation is to provide first-class API for Darwin platforms, with a focus on these goals (outlined in our README):

  • Providing basic utility types
  • Establishing consistent conventions
  • Support internationalization and localization
  • Provide a level of OS independence

As a part of the operating system, Foundation is often tasked with adding API that forms a part of a larger feature across a release. Foundation also adds other new API requested by developers (both internal and external) after the team has agreed upon its general utility, implemented and tested the functionality, and reviewed it.

Sometimes, features that Apple wants to add to Foundation will require changes to the Swift compiler or standard library. In those cases, the Foundation team at Apple will run a Swift Evolution proposal. Examples include SE-0161 Smart KeyPaths, SE-0166 Swift Archival & Serialization, SE-0167 Swift Encoders, and SE-0170 NSNumber bridging.

swift-corelibs-foundation

swift-corelibs-foundation is an open-source library created concurrently with the release of the Swift project. Its goal is to bring API parity with Foundation to non-Darwin platforms. These "core" APIs (along with XCTest and libdispatch) exist to support a broad level of common functionality that developers can rely upon for all Swift development across platforms.

A large subset of Foundation's implementation has actually been open source for a long time. This was imported into swift-corelibs-foundation to form a common base of implementation. This library is called CoreFoundation ("CF"). Over the past few years, Apple has open sourced some key parts of Foundation by moving them into CF. For example: CFURLComponents and CFCalendar Enumeration.

Thanks to an amazing level of effort from the open source community (highlighted above in this thread), an incredible amount of progress towards realizing this goal has been made.

The Intersection

These two projects have different goals, but of course they are also inexorably linked with each other.

  • Some implementation can be shared, as detailed above. The Foundation team at Apple is hoping to do more of this over time, and Swift reaching ABI stability will improve our ability to do so.
  • Most of the team that works on Foundation is also involved with swift-corelibs-foundation. This includes code review, rewriting Objective-C in Swift or C so it is more portable, and writing completely new implementations.
  • API added to Foundation should also be added to swift-corelibs-foundation, to maintain parity.

It is not a goal of swift-corelibs-foundation to add API to Foundation. However, the Foundation team does recognize the opportunity that Swift provides to take advantage of new language features to improve our interfaces. As these changes are made to Foundation, swift-corelibs-foundation also benefits. Examples include improved Scanner API and FileHandle API.

swift-corelibs-foundation is a hybrid open source project. It is clearly related to Foundation, but it does not bring all of Foundation to open source. The Foundation team welcomes suggestions for improvements to our APIs for Swift, including those in swift-corelibs-foundation. In addition, the Foundation team will continue to drive improvements to both projects on its own. As a key part of the operating systems and the Swift project, both Foundation and swift-corelibs-foundation are expected to be well supported and maintained alongside Swift itself.

Thanks,

Tony

18 Likes