Swift 4.2现已正式发布:更快编译时间,在泛型方面取得重大进展

Swift 4.2 现已正式发布!Swift 4.2 基于 Swift 4 的优势,提供更快的编译时间,改进调试体验,更新标准库以及融合二进制兼容性。随着对 conditional conformance 的支持,Swift 4.2 在泛型方面取得了重大进展,像是减少样板代码的数量,使更多代码可重用等等。要了解有关 conditional conformance 的更多信息,请参阅:

标准库更新

Swift 4.2 中的标准库包含许多新特性,比如 Hashable 协议的改进以及新的统一随机化函数(randomization functions)和协议集。

二进制兼容性

Swift 4.2 使语言更接近稳定的 ABI ,为未来的 Swift 版本实现二进制兼容性。访问 ABI Dashboard 可了解有关此项工作当前进展的更多详情。

其他语言和编译器更新

Swift 4.2 包含许多对开发者体验有显着影响的改进,包括:

  • Support for batch mode compilation resulting in faster build times

  • Change in calling convention for retain/release cycle to reduce code size and improve runtime performance

  • Lazier SIL deserialization with -Onone

  • Recursive metadata support

  • More compact reflection metadata

  • Default arguments are inlined at call sites

  • Some long-standing bug fixes, including init declname, switch with multiple case labels per block, inheritance of generic initializers, and more

Swift 4.2 还实现了 Swift Evolution 上的一些提案:

包管理器更新

Swift 4.2 为 Swift 包管理器引入了新功能:

  • 支持批处理模式. Swift targets will be now compiled using the Swift compiler’s batch mode.

  • Improved scheme generation logic. The scheme generation logic is improved and generates schemes as follows:

    • One scheme containing all regular and test targets of the root package.

    • One scheme per executable target containing the test targets whose dependencies intersect with the dependencies of the executable target.

  • Automatic Xcode project generation. The generate-xcodeproj has a new –watch option to watch the file system and automatically regenerate the Xcode project if needed. This uses the watchman tool to watch the required files.

Swift 4.2 还实现了 Swift Evolution 上关于包管理器的一些提案:

迁移说明和更新细节可查阅:

下载地址: