Skip to content

Introduction

Swift is a powerful and intuitive programming language created by Apple for building apps for iOS, Mac, Apple TV, and Apple Watch. It is designed to be fast, modern, and safe by design.

Features

  • Safe: Swift eliminates entire classes of unsafe code. Variables are always initialized before use, arrays and integers are checked for overflow, and memory is managed automatically.
  • Fast: Swift uses the high-performance LLVM compiler technology to transform Swift code into optimized native code that gets the most out of modern hardware.
  • Modern: Features like type inference, closures, tuples, generics, and powerful error handling make code more expressive and less prone to errors.
  • Open Source: Swift is developed in the open at Swift.org, with source code, a bug tracker, forums, and regular development builds available for everyone.

Development Settings

For the best experience in Xcode, consider tweaking these significant options:

  • Text Editing:
    • Line Numbers: SettingsText EditingDisplay → Check Line numbers.
    • Code Completion: SettingsText EditingEditing → Check Suggest completions while typing.
  • Indentation:
    • Prefer Spaces: SettingsText EditingIndentation → Set Tab width and Indent width (Swift standard is 4 spaces).
  • Intelligence (AI):
    • Swift Assist: SettingsText EditingEditing → Enable Predictive Code Completion for AI-powered suggestions.

Comments

Swift supports single-line, multi-line, and documentation comments.

swift
// This is a single-line comment

/* This is a
   multi-line comment */

/// This is a documentation comment.
/// Xcode will display this in the Quick Help inspector.