Ask HN: What is the best book for learning Swift?

11 points by hestefisk ↗ HN
I am an experienced programmer looking to get into iOS programming with Swift. I have experience in C#, Java, Perl and Python and used UNIX as a professional for more than 15 years. What's the best source to get started as an experienced professional?

7 comments

[ 5.1 ms ] story [ 47.2 ms ] thread
Not a book, but since your description asks for a "source":

Developing iOS 8 Apps with Swift[0]: Stanford course with a great professor that focuses on learning Swift with a heavy focus on the iOS SDK. Really great for getting the fundamentals for iOS programming, and the course assumes a solid programming background (e.g., MVC).

Book: Swift Programming: The Big Nerd Ranch Guide (Big Nerd Ranch Guides)[1]. This looks like it just came out, and I haven't read it, but I did read the authors' Obj. C Guide and their iOS Guide, and both were great, so I'm assuming the same for this one.

0 - https://itunes.apple.com/us/course/developing-ios-8-apps-swi... 1 - http://www.amazon.com/Swift-Programming-Ranch-Guide-Guides/d...

You don't really need to pay for a book. If you're experienced with C# it'll be pretty easy to pick up.

But, if you really want one, the definitive choice is "The Swift Programming Language", which is free: https://itunes.apple.com/us/book/swift-programming-language/...

"If you're experienced with C# it'll be pretty easy to pick up. But, if you really want one..."

I disagree with the implication that people who know C# can just jump in without reading anything. For starters, you have to learn the syntax somewhere. For example, I don't see how one could learn the way one writes try-catch in Swift without reading about it, or how one learns about 'let' and 'var'.

Secondly, there are deeper differences one has to learn. Some clear examples I can think of are:

  - protocols
  - collections are value types
  - checked integer arithmetic is the default
  - the way strings are sequences of extended grapheme clusters,
    not of bytes or Unicode code points
So, read the book. If you know C# (or any remotely Algol-, Pascal- or C-like language), lots will be familiar, but there will be bits to learn that would be huge stumbling blocks if you didn't know about them.
If you are looking to build iOS apps, Swift is one piece of the puzzle. You will have lot to learn about libraries from Apple and others's to make you productive. Stanford's course and courses on Udemy are a good start. I like Stanford's course better because it is tailored for someone who has some experience in programming, however Udemy course is bit more pragmatic. Be patient and be willing to put in time.
Have been doing iOS programming with Swift 2.5 days per week for a bit less than a year now. The first step I took was to read through Apple's Official Swift Language Guide[0]. After completing this I followed the Stanford course on iOS Development with Swift[1]. I didn't spend much time on this, I did this in a Friday afternoon(language guide) and full weekend(watching lectures), since I believe more in learning by practicing.

I've really come to like Swift as a language, since it's concise and simple. The iOS SDK however is not so much fun. Learning the iOS SDK will take a lot of time before you develop routines to approach your problems. I'm still learning about strange behaviour from the SDK and getting frustrated by it every time I use it. It's important to keep things fun, look through the trending Swift repositories on GitHub, follow #iosdev on Twitter and /r/iosprogramming, you will learn a lot if you keep up to date with these sources.

Some of the habits I've created, which might be handy to other people:

- I manage dependencies with CocoaPods, with no dependencies residing in my repository.

- I don't use storyboards or xib's at all. Everything I do is with SnapKit[2]. This takes some time to learn, but it greatly improves the diffs and overview on how the ui elements are constrained and set up.

- I use API endpoint enums which get called by an API Handler, which uses Alamofire[3] to execute the api requests.

- I try to use as many tools provided by Fastlane[4]. Especially if you're developing many Apps, or incrementally building an App, releasing a new version every two weeks: automate all the things. Otherwise you will waste so much time simply waiting for a process to complete.

Side note(if you're interested):

I'm currently developing a tool called Evans(will write a blog post as soon as it's reasonably finished), which performs all kinds of routines automatically. It for example listens to GitHub comments like '@evans screenshots' on a pull request. Evans then emits a request to one of the build slaves, which retrieves the branch, builds the project and runs the screenshot routine, puts the screenshots in an s3 bucket and posts a link as a response in the pull request.

[0] - https://developer.apple.com/library/ios/documentation/Swift/...

[1] - https://itunes.apple.com/us/course/developing-ios-8-apps-swi...

[2] - https://github.com/SnapKit/SnapKit

[3] - https://github.com/Alamofire/Alamofire

[4] - https://github.com/fastlane/fastlane