swiftlang/swift-corelibs-foundation logo

swiftlang/swift-corelibs-foundation

Free

The Foundation Project, providing core utilities, internationalization, and OS independence

FreeFree tier
Type
Open Source

About swiftlang/swift-corelibs-foundation

The Foundation framework defines a base layer of functionality required for almost all applications. It provides primitive classes and introduces several paradigms that define functionality not provided by either the Objective-C runtime and language or Swift standard library and language. This project, swift-corelibs-foundation, provides a compatibility implementation of the Foundation API for platforms where there is no Objective-C runtime. On macOS, iOS, and other Apple platforms, apps should use the Foundation that comes with the operating system. The project is composed of swift-foundation (core implementation of key types like URL, Data, JSONDecoder, Locale, Calendar), Swift Corelibs Foundation (compatibility API for pre-Swift API, providing NSObject, class-based data structures, NSFormatter, NSKeyedArchiver), and Foundation ICU (private library wrapping ICU).

Key Features

Provides a base layer of functionality for Swift applications
Includes core utility classes and data structures
Supports internationalization and localization
Offers OS independence for portability
Compatibility implementation for non-Apple platforms
Includes swift-foundation with types like URL, Data, JSONDecoder, Locale, Calendar
Swift Corelibs Foundation provides NSObject, class-based data structures, NSFormatter, NSKeyedArchiver
Foundation ICU wrapper for consistent internationalization behavior

Pros & Cons

Pros
  • Open source and free
  • Part of the official Swift ecosystem
  • Provides OS independence and portability
  • Comprehensive internationalization support
  • Includes both modern swift-foundation and compatibility layers
Cons
  • Best-effort compatibility with Objective-C Foundation (not a drop-in replacement)
  • Not intended for use on Apple platforms (use native Foundation)
  • May have performance or behavior differences from Apple's Foundation
  • Requires ICU library for some internationalization features

Best For

Developing cross-platform Swift applications that need Foundation API on Linux or WindowsPorting Objective-C code that relies on Foundation to non-Apple platformsBuilding server-side Swift applications with Foundation utilitiesUsing Swift on platforms without Objective-C runtime

FAQ

What is swift-corelibs-foundation?
It is an open-source compatibility implementation of the Foundation framework for Swift on platforms without an Objective-C runtime, such as Linux and Windows.
How does it relate to swift-foundation?
swift-foundation is a shared library providing core implementation of key types like URL and Data. swift-corelibs-foundation provides a broader compatibility API and re-exports swift-foundation modules.
Can I use this on macOS or iOS?
No, Apple platforms should use the Foundation that comes with the operating system. This project is for non-Darwin platforms.