Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of Swift 3 API Design criteria

2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

Editor to share with you the example analysis of Swift 3 API design guidelines, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

The design concept of a standard library of programming languages 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 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 them consistently.

The Swift API design guidelines include several main goals, all of which aim to unify the development style of Swift. These main objectives are:

Swift API design criteria: we are currently actively developing the actual API design criteria. At present, the sample draft of the Swift API design guidelines is available!

Swift standard library: the entire Swift standard library is being reviewed and updated to be able to follow Swift API design guidelines. The actual work is being done in the swift-3-api-guidelines branch of the Swift repository.

Import Objective-C API: work is under way to translate Objective-C API into Swift, using several heuristic logic to make Objective-C API better match Swift API design guidelines. The proposal of Objective-C API's Swift translation guide describes which translation method is effective. Of course, because this process uses a series of heuristic logic methods, we track its impact on Cocoa and Cooca Touch, including the work of Swift code that uses these frameworks. The Swift 3 API Design Guide Review Warehouse provides a way to view this automatic translation process to see the impact on Swift code that uses Cocoa and Cocoa Touch. Some special Objective-C API that will not be translated into Swift will be marked (for example, using NS_SWIFT_NAME macros) to improve the quality of the resulting Swift code. Although this change mainly affects the Apple platform, it also has a direct impact on cross-platform Swift core libraries that provide the same API as the Objective-C framework, such as the Objective-C runtime used in Swift.

Swift design guidelines check: existing Swift code follows different coding styles, and even includes Objective-C code guidelines for Cocoa. With the heuristic logic used to import Objective-C API, the Swift compiler can examine common API design patterns, identify API that do not meet Swift API design guidelines, and make recommendations.

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

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

The above is all the content of the article "sample Analysis of Swift 3 API Design guidelines". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report