{"id":22807,"date":"2018-09-19T14:59:06","date_gmt":"2018-09-19T18:59:06","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=22807"},"modified":"2018-09-24T11:36:42","modified_gmt":"2018-09-24T15:36:42","slug":"swift-4-2-released","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2018\/09\/19\/swift-4-2-released\/","title":{"rendered":"Swift 4.2 Released"},"content":{"rendered":"<p><a href=\"https:\/\/swift.org\/blog\/swift-4-2-released\/\">Ted Kremenek<\/a>:<\/p>\n<blockquote cite=\"https:\/\/swift.org\/blog\/swift-4-2-released\/\">\n<p>Swift 4.2 is now officially released! Swift 4.2 builds on the strengths of Swift 4, delivering faster compile times, improving the debugging experience, updating the standard library, and converging on binary compatibility.<\/p>\n<p>[&#8230;]<\/p>\n<p>The standard library in Swift 4.2 includes a number of new features, including improvements to the Hashable protocol as well as a new unified set of randomization functions and protocols.<\/p>\n<p>See more at:<\/p>\n<ul>\n  <li><a href=\"https:\/\/github.com\/apple\/swift-evolution\/blob\/master\/proposals\/0197-remove-where.md\">SE-0197 Adding in-place removeAll(where:) to the Standard Library<\/a><\/li>\n  <li><a href=\"https:\/\/github.com\/apple\/swift-evolution\/blob\/master\/proposals\/0199-bool-toggle.md\">SE-0199 Adding toggle to Bool<\/a><\/li>\n  <li><a href=\"https:\/\/github.com\/apple\/swift-evolution\/blob\/master\/proposals\/0202-random-unification.md\">SE-0202 Random Unification<\/a><\/li>\n  <li><a href=\"https:\/\/github.com\/apple\/swift-evolution\/blob\/master\/proposals\/0204-add-last-methods.md\">SE-0204 Add last(where:) and lastIndex(where:) Methods<\/a><\/li>\n  <li><a href=\"https:\/\/github.com\/apple\/swift-evolution\/blob\/master\/proposals\/0206-hashable-enhancements.md\">SE-0206 Hashable Enhancements<\/a><\/li>\n  <li><a href=\"https:\/\/github.com\/apple\/swift-evolution\/blob\/master\/proposals\/0207-containsOnly.md\">SE-0207 Add an allSatisfy algorithm to Sequence<\/a><\/li>\n<\/ul>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/Javi\/status\/1042060475997880320\">JaviAir<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/Javi\/status\/1042060475997880320\">\n<p>A year later, and Swift 4.2 shipped with a <a href=\"https:\/\/bugs.swift.org\/plugins\/servlet\/mobile#issue\/SR-6795\">ship-stopper KVO bug<\/a> still unresolved. Don&rsquo;t use the Swift KVO syntax in an iOS app unless you want random crashes.<\/p>\n<\/blockquote>\n\n<p>Previously: <a href=\"https:\/\/mjtsai.com\/blog\/2018\/06\/07\/swift-4-2\/\">Swift 4.2<\/a>.<\/p>\n\n<p id=\"swift-4-2-released-update-2018-09-20\">Update (2018-09-20): <a href=\"https:\/\/www.swiftbysundell.com\/posts\/enum-iterations-in-swift-42\">John Sundell<\/a>:<\/p>\n<blockquote cite=\"https:\/\/www.swiftbysundell.com\/posts\/enum-iterations-in-swift-42\">\n<p>Instead of manually defining our font dictionary, like we do above, let&rsquo;s take a look at how Swift 4.2&rsquo;s <code>CaseIterable<\/code> can help us avoid bugs and make our code more consistent when defining enum-keyed dictionaries.<\/p>\n<\/blockquote>\n\n<p><a href=\"http:\/\/khanlou.com\/2018\/09\/bloom-filters\/\">Soroush Khanlou<\/a>:<\/p>\n<blockquote cite=\"http:\/\/khanlou.com\/2018\/09\/bloom-filters\/\"><p>Ideally, you&rsquo;d be able to initialize the <code>Hasher<\/code> with a seed, instead of mixing it in. Swift&rsquo;s <code>Hasher<\/code> uses a different seed for each launch of the application (unless you <a href=\"https:\/\/github.com\/apple\/swift-evolution\/blob\/master\/proposals\/0206-hashable-enhancements.md#effect-on-abi-stability\">set an environment variable<\/a> which they added for consistent hashing between launch, mostly for testing purposes), meaning you can&rsquo;t write these values to disk. If we controlled the seed of the <code>Hasher<\/code>, then we could write these values to disk as well. As this Bloom filter currently stands, it should only be used for in-memory caches.<\/p><\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/layoutSubviews\/status\/1042627562575282176\">Renaud Lienhart<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/layoutSubviews\/status\/1042627562575282176\">\n<p>I think this is new in the Swift 4.2 toolchain: it is now possible to declare a nested type in an extension, <em>in a different file<\/em> than the one with the parent type&rsquo;s declaration.\nThis will clean up things nicely<\/p>\n<\/blockquote>\n\n<p id=\"swift-4-2-released-update-2018-09-24\">Update (2018-09-24): See also: <a href=\"https:\/\/developer.apple.com\/documentation\/xcode_release_notes\/xcode_10_release_notes\/swift_4_2_release_notes_for_xcode_10?language=objc\">Swift 4.2 Release Notes for Xcode 10<\/a>.<\/p>\n\n<p><a href=\"https:\/\/swiftrocks.com\/how-caseiterable-works-internally-in-swift.html\">Bruno Rocha<\/a>:<\/p>\n<blockquote cite=\"https:\/\/swiftrocks.com\/how-caseiterable-works-internally-in-swift.html\"><p>You can reverse engineer the resulting binary, but it would be painfully hard to understand what the [<code>CaseIterable<\/code>] assembly means. Another option is to fork the Swift compiler and attach lldb to it, but you would need to know what to breakpoint in the first place - which I have no idea.<\/p><p>Luckily, the Swift compiler in your Xcode&rsquo;s toolchain offers several arguments that allow you to extract human-readable files that represent &ldquo;processed&rdquo; versions of Swift source files, and one of these options allow you to retrieve the <b>Abstract Syntax Tree (AST)<\/b> of a file.<\/p><\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Ted Kremenek: Swift 4.2 is now officially released! Swift 4.2 builds on the strengths of Swift 4, delivering faster compile times, improving the debugging experience, updating the standard library, and converging on binary compatibility. [&#8230;] The standard library in Swift 4.2 includes a number of new features, including improvements to the Hashable protocol as well [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2018-09-19T18:59:09Z","apple_news_api_id":"4807499c-745b-4099-b344-5157c49f7369","apple_news_api_modified_at":"2018-09-24T15:36:45Z","apple_news_api_revision":"AAAAAAAAAAAAAAAAAAAAAw==","apple_news_api_share_url":"https:\/\/apple.news\/ASAdJnHRbQJmzRFFXxJ9zaQ","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[131,69,31,1610,275,30,1609,71,901],"class_list":["post-22807","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-bug","tag-cocoa","tag-ios","tag-ios-12","tag-keyvalueobserving","tag-mac","tag-macos-10-14","tag-programming","tag-swift-programming-language"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/22807","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=22807"}],"version-history":[{"count":5,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/22807\/revisions"}],"predecessor-version":[{"id":22848,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/22807\/revisions\/22848"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=22807"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=22807"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=22807"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}