Swift 4 is available in Xcode 9 (which went live on the Mac App Store earlier today) and we will be posting an official toolchain shortly as well (likely early tomorrow morning).
Official builds have been posted for Linux (Ubuntu 16.10, Ubuntu 16.04 and Ubuntu 14.04). For those of you downloading the Linux builds, please note that there is a new signing key (search for 'Swift 4.x Release Signing Key’) on the downloads page:
And as a PSA: Data is its own slice type in Swift 4, and Data slices are not copied correctly when COW is invoked on them (see: SR-5810). The workaround, for now, is to cast any Data for which you want to make a mutable copy to NSData and back. So, rather than this:
func doSomething(with data: Data) {
var mutableData = data
mutableData.append(0x01)
print("modified data: \(mutableData as NSData))")
}
do this instead:
func doSomething(with data: Data) {
var mutableData = data as NSData as Data
mutableData.append(0x01)
print("modified data: \(mutableData as NSData))")
}
Otherwise, if ‘data’ happens to be a slice, the data you end up with will be corrupt. Also, in certain circumstances, making a mutable copy of a slice and appending to it can cause data to be written past the end of its parent Data’s buffer, which can either make your app crash or corrupt other memory in the program.
Be careful!
Charles
···
On Sep 19, 2017, at 9:06 PM, Ted Kremenek via swift-users <swift-users@swift.org> wrote:
I am pleased to announce that Swift 4.0 has been officially released:
Swift 4 is available in Xcode 9 (which went live on the Mac App Store earlier today) and we will be posting an official toolchain shortly as well (likely early tomorrow morning).
Official builds have been posted for Linux (Ubuntu 16.10, Ubuntu 16.04 and Ubuntu 14.04). For those of you downloading the Linux builds, please note that there is a new signing key (search for 'Swift 4.x Release Signing Key’) on the downloads page: