JohnSundell / ShellOut

Easily run shell commands from a Swift script or command line tool
MIT License
872 stars 85 forks source link

inconsistency with builds #15

Closed MasterSwift closed 6 years ago

MasterSwift commented 6 years ago

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.

JohnSundell commented 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.

MasterSwift commented 6 years ago

Another alternative is to place the files in a folder that is NOT under the Sources folder.