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: Settings → Text Editing → Display → Check Line numbers.
    • Code Completion: Settings → Text Editing → Editing → Check Suggest completions while typing.
  • Indentation:
    • Prefer Spaces: Settings → Text Editing → Indentation → Set Tab width and Indent width (Swift standard is 4 spaces).
  • Intelligence (AI):
    • Swift Assist: Settings → Text Editing → Editing → 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.