Hello Swift!To begin, let’s write a simple Swift program together. In the left window labeled source code, enter the following line of code:
print("Hello Swift!")New to Swift? Check out the official language guide. Hit the blue run button located at the top to execute the program. If everything was entered correctly, “Hello Swift!” should appear under output in the results window. If we edit the previous example and omit the closing parenthesis at the end of the line, an error should get flagged by the editor. Hover over the red marker that appears next to the line number to examine the error message. Error messages are also listed in the output.
Swift Meets LinuxWe’ve provided a collection of sample programs for you to experiment with. Click Source Samples in the upper left corner to see the list of available sample programs. For instance, select filestat.swift and run the program. The output generated should be similar to what’s seen below:
/bin/bash is 1037464 bytesIf we try changing the value of
filenameon line 12 from “/bin/bash” to “/tmp”, we should see a different number of bytes printed. You may have noticed that this program is calling
statfrom glibc (The GNU C Library). Since the sandbox runs on top of Linux, we can write Swift code that interacts directly with the system. Take a look at some of the other samples for more examples of using glibc.