I've been trying to locate a transition guide for Swift 2, in particular things developers should be aware of when migrating Swift 1/1.2 codebases over to Swift 2. Obviously you have the migration assistant in Xcode, but that only really covers the donkey work and not the stuff that requires a bit more intelligent thought.
Based on the resources I was able to find on Swift 2, I've put together the following checklist:
NSError
and calling back to delegates to report recoverable errors.enums
conforming to ErrorType
to define your own meaningful errors.do { }
to control scope and free large resources earlydo { ... } while
loops to repeat { }
(to remove ambiguity and improve readability)guard
to return early and avoid excessive indentationdefer
for cleanup code like closing files etc.viewAnimationOptions = [.Repeat, .CurveEaseIn, .TransitionCurlUp]
)public
accessor specifiers which were previously only required to support testing. Use @testable
and import MyApp
instead.switch
statements to the new if case .MyEnumCase(let value) = bar() where value != 42 { doThing(value) }
for
loops containing if
filtering statements e.g. for value in mySequence where value != "" { }
Sources:
https://developer.apple.com/swift/blog/?id=29
https://developer.apple.com/swift/
https://developer.apple.com/library/prerelease/ios/releasenotes/DeveloperTools/RN-Xcode/Chapters/xc7_release_notes.html#//apple_ref/doc/uid/TP40001051-CH5-SW1
https://developer.apple.com/videos/wwdc/2015/?id=106
http://www.raywenderlich.com/108522/whats-new-in-swift-2
What have I missed?
Part of the problem is that Swift 2 has continued to evolve past WWDC. So even this year's WWDC videos are already potentially out of date, or at least not the whole story.
Unfortunately, at this time there is no official "transition guide" from Apple as such.
The Swift Programming Language (Swift 2) is always updated by Apple whenever they release a new version of Swift and is therefore one of the best sources for up to date information about Swift 2 (or later). There is plenty of explanation and example code of the entire language, not just the changes, but this is definitely at least on of the best sources for the information you are looking for right now.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With