Closed MasterSwift closed 6 years ago
Yeah, that's exactly why I created Marathon 🙂 Only main.swift
in a command line application or a single script file can contain top level code in Swift. When you use swift build
you are compiling all of your source files as a Swift package, and such files can't contain top level code. So I would suggest either using a main.swift
file for all your top level code, or use Marathon.
Another alternative is to place the files in a folder that is NOT under the Sources
folder.
In a Swift scripts folder under my project-directory , I have a few swift files that generate build errors (from the error: "statements are not allowed at the top level") when I run "swift build" in the project folder. However when running "marathon run myfile.swift" in the Swift script folder , it runs and generates the proper output.