When you want to test a simple expression like print("Hello, World!") on the top level, it needs to be written in a fixed file main.swift, no other file names are allowed.
And main.swift would only work with the project template: macOS Command Line Tool.
Create a new project macOS Command Line Tool, and edit main.swift.
Or if you want to test your code in a GUI app, you need to move the line print("Hello, World!") into some function.
Topic:
Programming Languages
SubTopic:
Swift
Tags: