Shared Swift Runtime for Apps
Binary Frameworks
Apple Swift-Only Frameworks
Package Manager in Xcode
More API Expressibility
Library Evolution
What is ABI?
ABI = "Application Binary Interface"
Specified details of a program's representation at runtime
Compatible ABIs allows separately complied code to interact at runtime
Before ABI stability these both need to be built with the came compiler
ABI stability in Swift 5
Program and framework can be built with different compilers (Swift 5 or later)
What is Module Stability?
Swift libraries and the APIs they export are known as "modules"
Module files are created (and used) by the compiler
Module + ABI stability = Binary frameworks
//WWDC 2019
Binary Frameworks in Swift
Adopting Swift Packages in Xcode
Creating Swift Packages
Apps and the Shared Swift Runtime in the OS
Apps use the runtime from OS when it is available
Apps that backward deploy contain a runtime copy
·Embedded runtime copy is inert on OSs with shared runtime
·iOS AppStore thins out runtime copy when downloading to iOS 12.2 or later
Launch time overhead with Swift 5 = 0%
Faster Bridging Between Swift and Objective-C
NSDictionary to Dictionary Bridging 1.6x faster
NSString operations when performed on bridged Swift Strings 15x faster
Native Swift Strings now interoperate with C APIs without overhead
Small Strings include Unicode characters in addition to ASCII
Fast Interoperability with NSString
SwiftNIO
Swift Sourcekit
Language and Standard Library
在SwiftUI的Text可以自动实现国际化
@propertyWrapper
Wrapper types define custom access patterns
Property can adopt by adding an attribute to its declaration
Define Embedded DSLs in Swift
html {
head {
title(...)
}
body {
h2 { ... }
br()
"....."
a {
"..."
}.href("http...")
//还可以用Swift的控制
if !loggedIn {
button {
...
}
.onclick("")
}
}
}
网友评论