Swift 3 API Design Guidelines

Swift 3 API Design Guidelines

[[158193]]

The design concept of a programming language's standard library often has a great impact on the overall feeling of the programming language. A good standard library is like an extension of the language itself, and ensuring the consistency within the standard library can effectively improve the overall development experience. In order to build a good Swift standard library, one of the main goals of Swift 3 is to define a set of API design guidelines and apply these guidelines consistently.

The Swift API design guidelines contain several main goals, all of which are aimed at unifying the development style of Swift. These main goals are:

  • Swift API Design Guidelines: The actual API design guidelines are currently under active development. Currently, the first draft of the Swift API Design Guidelines is available for viewing!

  • Swift Standard Library: The entire Swift standard library is being reviewed and updated to follow the Swift API Design Guidelines. The actual work is happening in the swift-3-api-guidelines branch of the Swift repository.

  • Importing Objective-C APIs: Work is underway to translate Objective-C APIs into Swift, using several heuristics to better match the Swift API design guidelines. The proposed Swift translation guidelines for Objective-C APIs describes which translations are available. Of course, since this process uses a series of heuristics, we will track its impact on Cocoa and Cocoa Touch, including the work of Swift code using these frameworks. The Swift 3 API Design Guidelines Review repository provides a way to view this automatic translation process to see the impact on Swift code using Cocoa and Cocoa Touch. Certain Objective-C APIs that will not be translated into Swift will be marked (for example, using the NS_SWIFT_NAME macro) to improve the quality of the resulting Swift code. While this change primarily affects Apple platforms, it will also have some direct impact on cross-platform Swift core libraries that provide the same APIs as Objective-C frameworks (such as the Objective-C runtime used in Swift).

  • Swift Design Guidelines Check: Existing Swift code follows different coding styles, including Objective-C coding guidelines for Cocoa. With the heuristic logic used to import Objective-C APIs, the Swift compiler can check for common API design patterns, find APIs that do not meet the Swift API Design Guidelines, and provide suggestions.

  • Swift 2 migration to Swift 3: Swift standard library and importing Objective-C API will be a major update of Swift, and a new correction operation will be made to the source code. Therefore, we also need to create a migrator that can migrate Swift 2 code to Swift 3 API.

All of these major efforts are under active development. If you are interested in following the work, you can check out the Swift API design guidelines, the Swift standard library changes, the Objective-C API importer changes proposal, and the current review repository, and join the discussion on the swift-evolution mailing list.

<<:  Google's latest app Cardboard Camera turns your phone into a VR camera

>>:  iOS 9 adoption rate slowed down, increasing by 4 percentage points to 70% in November

Recommend

How to choose a reliable Douyin agent?

Weibo, Weibo and Douyin have become the standard ...

Android Studio Development Skills Collection 1

About Android Studio's key mapping Android St...

User operation strategy plan

The article divides Someet users into a pyramid m...

How do physical stores operate private domain traffic?

Private domain traffic is the life-saving straw f...