Swift Core Libraries
The Swift Core Libraries project provides higher-level functionality than the Swift standard library. These libraries provide powerful tools that developers can depend upon across all the platforms that Swift supports. The Core Libraries have a goal of providing stable and useful features in the following key areas:
- Commonly needed types, including data, URLs, character sets, and specialized collections
- Unit testing
- Networking primitives
- Scheduling and execution of work, including threads, queues, and notifications
- Persistence, including property lists, archives, JSON parsing, and XML parsing
- Support for dates, times, and calendrical calculations
- Abstraction of OS-specific behavior
- Interaction with the file system
- Internationalization, including date and number formatting and language-specific resources
- User preferences
These libraries are part of our ongoing work to extend the cross-platform capabilities of Swift. We chose to make them part of our open source release so that we can work on them together with the community.
Writing code that provides all of this functionality from scratch would be an enormous undertaking. Therefore, we’ve decided to bootstrap this project by taking advantage of great work that has already been done in these areas. Specifically, we will reuse the API and as much implementation as is possible from three existing libraries:
The Foundation framework defines a base layer of functionality that is required for almost all applications. It provides primitive classes and introduces several paradigms that define functionality not provided by the language or runtime. It is designed with these goals in mind:
- Provide a small set of basic utility classes.
- Make software development easier by introducing consistent conventions.
- Support internationalization and localization, to make software accessible to users around the world.
- Provide a level of OS independence, to enhance portability.
More information about the Foundation framework in general is available from Apple’s documentation. The Swift.org version of Foundation makes use of many of the same underlying libraries (e.g. ICU and CoreFoundation) as Apple’s implementation, but has been built to be completely independent of the Objective-C runtime. Because of this, it is a substantial reimplementation of the same API, using pure Swift code layered on top of these common underlying libraries. Much more information about this work is available on our GitHub project page.
Grand Central Dispatch (GCD or libdispatch) provides comprehensive support for concurrent code execution on multicore hardware.
libdispatch is currently available on all Darwin platforms. This project aims to make a modern version of libdispatch available on all other Swift platforms. To do this, we will implement as much of the portable subset of the API as possible, using the existing open source C implementation.
More information about libdispatch for Linux is available on our GitHub project page.
The XCTest library is designed to provide a common framework for writing unit tests in Swift, for Swift packages and applications.
This version of XCTest uses the same API as the XCTest you are familiar with from Xcode. Our goal is to enable your project’s tests to run on all Swift platforms without having to rewrite them.
More information about XCTest on Linux is available on our GitHub project page.
As stated above, this project is in its early days. We look forward to working together with the community to create a great set of libraries that enable Swift to produce powerful software across platforms.