How do I import other Swift files into a Swift script? [duplicate] How do I import other Swift files into a Swift script? [duplicate] swift swift

How do I import other Swift files into a Swift script? [duplicate]


There's currently no way to import other swift files in a interpreted swift script. But you can concatenate all source files before executing them:

cat one.swift two.swift three.swift | swift -

If you're using the swift compiler, just add the files you want to compile together before the -o argument:

swiftc one.swift two.swift three.swift -o combined

No need to import them, they are already in the same module.