If you call this example with a URL that can return a list of todos it'll print a nice list of the items./main.swift joined(separator: "\n"))įatalError( "Error: \(error. With the help of Foundation we can build quite useful or completely useless command line utilities. The good news is that we can import all sort of system frameworks that are part of the Swift toolchain. Thanks to the program-loader mechanism and of course the Swift interpreter we can skip an extra step and run our single-source Swift code as easy as a regular shell script. main.swift file it'll print out the famous "Hello world!" text. The good news that we can take this one step further by auto-invoking the Swift compiler under the hood with a shebang. In Swift if we want to print something, we don't even have to import the Foundation framework, we can simply compile and run this piece of code by running the following: swiftc main.swift # compile main.swiftĬhmod x main # add the executable permission Consider the most simple Swift program that we can all imagine in a main.swift file: print( "Hello world!") Swift compiler 101, you can create, build and run a Swift file using the swiftc command.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |