Back to Blog

Swift in VSCode: Write the first hello world program

Sandy LaneSandy Lane

Video: Swift in VSCode: Write the first hello world program by Taught by Celeste AI - AI Coding Coach

Watch full page →

Swift in VSCode: Write the First Hello World Program

Getting started with Swift in Visual Studio Code is simple and efficient for writing your first programs. In this guide, you'll learn how to create and run a basic "Hello, World!" application using Swift within VSCode, setting the foundation for further Swift development outside of Xcode.

Code

// This is a simple Swift program that prints "Hello, World!" to the console
print("Hello, World!")

Key Points

  • Swift code files use the .swift extension and can be edited in VSCode with Swift extensions installed.
  • The print() function outputs text to the console, making it ideal for simple programs and debugging.
  • Running Swift code in VSCode requires having Swift installed on your system and configured in your PATH.
  • You can execute Swift scripts directly in the terminal by running swift filename.swift.
  • VSCode offers syntax highlighting and code completion for Swift when the appropriate extensions are installed.