What is Swift?
Swift is an open source, general-purpose programming language developed by Apple Inc. They describe it as:
Swift is a powerful and intuitive programming language for macOS, iOS, watchOS and tvOS. Writing Swift code is interactive and fun, the syntax is concise yet expressive, and Swift includes modern features developers love. Swift code is safe by design, yet also produces software that runs lightning-fast.1
Want to try out Swift right now? Repl.it offers an online Read-Eval-Print loop for Swift. You won't have access to UIKit or other APIs that are commonly used, but give it a shot!
To declare a variable in Swift, simply use var followed by the name of your variable.
var x = 6 var name = "Bob" var boole = true x = 3
Constants are similar to variables, but they cannot change in value after creation.
let x = 6 let name = "Bob" let boole = true
To print anything to the standard output, simply use print() and place your output in the parentheses.
let x = "World" print("Hello ") print(x)
The latest version is Swift 4.2, released Sept. 17, 2018. Swift is constantly evolving, and you can expect more changes in the future. It is recommended you use the latest version of Swift when starting a new project.
Swift is heavily documented. Keep in mind that coding Swift involves not just using the language, but also many APIs. The best way to learn Swift is to make a project or application, no matter how small!
Developing iOS Apps (Swift): Want to make iOS Apps? This is a great place to start.
Language Guide: Has an overview of just about every feature in Swift. If you get confused when reading someone else's code, this document can help you.
Want to learn more?
- RayWenderlich.com : Has many great tutorials for Swift and iOS development.
- Hacking with Swift : A complete Swift tutorial, taking you from a beginner to advanced using hands-on projects.
- CodewithChris.com : Xcode work environment education
- Stanford course : Excellent course held by the professor at Stanford university
- Basic app : Applying Swift knowledge in order to create a basic app that involves adding, listing, rating, deleting items
- Main Swift documentation: Good documentation regarding syntax
- Main Swift book : Main Swift book available on iTunes
- "Swift 4 - The powerful programming language that is also easy to learn." Apple, developer.apple.com/swift, Accessed 31 Oct. 2017.