How to avoid "Expressions are not allowed at the top level"

I repeatedly failed to code and run, with MacOS Monterey, Xcode and Swift, an app that simply sends "hello world" to the console. The result remained "Expressions are not allowed at the top level". Could anyone fully desribe a simple solution? Thanks in advance

Replies

Oops, sorry! The solution was already documented: place the print() statement in a newfile named main.swift, and run it. End of the subject for me.