Swift Foundation Preview released

A few months ago, the Swift community announced that the Foundation framework would be rewritten in pure Swift to improve cross-platform development in Swift. Recently, Foundation, which was rewritten based on Swift, released its first preview version.

The Foundation framework is the core of Apple's macOS and iOS basic component support. Almost all Swift projects use the Foundation framework. It mainly contains a large number of commonly used APIs, providing a basic layer for many basic functions and laying the foundation for writing excellent Swift code. base.

The release announcement reads that this preview provides a faster and safer implementation of Foundation, and a new Foundation working group has been established to coordinate the needs of the Swift community with the needs of Apple engineering.

The new Foundation builds many types of Swift implementations, including JSONEncoder, Calendar, TimeZone, and Locale, among others, as well as a separate package called FoundationICU for internationalization support on non-Darwin platforms.

Additionally, the new implementation, written in Swift, offers significant performance improvements over the previous C and Objective-C versions in areas such as JSON decoding and date formatting.

Swift Foundation provides a brand new Swift implementation for JSONDecoderand JSONEncoderthat eliminates expensive round trips to and from Objective-C collection types. Tight integration of parsing JSON to initialize types in Swift Codablealso improves performance. On a benchmark parsing test data, decoding time improved from 200% to nearly 500%.

The development team stated that quality and performance were two of their most important goals for the project. Therefore, the plan for the first half of 2023 is to continue refining the core API, adding unit and performance test suites, and extending to other platforms where possible, using the most relevant code from swift-corelibs-foundation.

As a secondary goal, the project asks the community to propose additions of new APIs with focused scope to complement existing API functionality in Foundation.

URL Later this year, porting of high-quality Swift implementations of other Foundation APIs, such as ,  Bundle ,  FileManager ,  FileHandle ,  Process ,  SortDescriptor , ,  will continue  SortComparator .

Guess you like

Origin www.oschina.net/news/239362/swift-foundation-preview