Hi, so I want to dip my feet into coding in swift, and I just started swift playgrounds. I find the whole guiding your character from one place to another very overwhelming, and I don’t feel like I’m completely understanding what I’m supposed to input for the code. Everything I tried had an issue. One moment,I’m being told I have to separate consecutive codes with a semicolon, and then I’m being told not to input a semicolon. Bottom line, i don’t know what I’m doing. I’m not completely giving up or anything, but is there another accessible way to learn swift I can try? Thanks and have a good day.
Comments
Code Swift
I remember an app mentioned on here called Code Swift for the iPhone and iPad which is supposed to help you learn Swift. I installed it but have yet to actually try it. Here's a link to the thread: https://www.applevis.com/apps/ios/education/code-learn-swift-version
Learn with the Swift REPL
I'd recommend to try out the Swift REPL (read-eval-print-loop). With this approach, you will have an interactive way to learn Swift and try out things with immediate feedback by the REPL.
Then, I'd use the 100 days of SwiftUI course by Paul Hudson on Hacking With Swift, but only the first 15 days from there. This will teach the basics and you can try out the things that were mentioned in the REPL after reading.
To use the REPL, you will need a Mac with the xcode command line tools installed. Then, you read through a tutorial and try out things in the REPL.
And I strongly encourage you to try out every piece, no matter how small it is. For example, assigning a variable, printing that out. Calculating with integers and so on.
If you prefer to write your code, save it, and then run it, you could also use the Swift Package Manager to do that. Then, you could read the tutorials by Paul Hudson that intorduce the basics, try out things by writing it into a .swift file and then run it with the command swift run. The Package Manager will set up a project with a main.swift file where you can write your code.
Thanks
Thanks, everybody
Beware of searching the web
I tried to learn Swift around the time of Swift v4. If I didn't know how to do something, I'd search the web. "Swift for loop syntax," or whatever. The problem was, each new version of Swift contained incompatible changes from previous versions, and information persists on the web forever. So I might find the syntax for a for loop described in some discussion forum, write my code based on that info, and then get a compile error because the syntax had changed.
Avoid my mistake. If you're completely new to Swift, but you know how to program, the current Swift reference manual is probably all you need. Here's the official language reference website.
The 100 Days of SwiftUI…
The 100 Days of SwiftUI tutorial is updated regularly and explains things very well, especially the basics of Swift can be followed pretty easily.
If you want to know more about Swift REPL or SwiftPM (Swift Package Manager), feel free to message me.