-
Book Overview & Buying
-
Table Of Contents
Mastering Swift 5.3 - Sixth Edition
By :
There is a lot that you can do with the package manager that makes it a necessity for creating complex applications on the Linux platform. It helps with adding dependencies to projects and enables us to break our code up into multiple files and create library projects. You can use the package manager on the Mac platform as well, but I do find it easier to use Xcode.
For the examples in this book, we will not need to add dependencies or use multiple files. Let's see how we can simply build and run an executable project in the package manager so you can use it to run the examples from this book if you would like. Keep in mind you are able to use the package manager on the Apple platform as well. When the package manager created main.swift in the Sources/test/ directory it added the following code to it:
print("Hello, world!")
This code gives us the basic Hello World application. You can replace this code with examples from this book as you are going through it. To see how we would build and run an application using the package manager, let's leave the code as is for now and run the following commands:
swift build
swift run
You should see the following output:
Hello, world!
The swift build command compiled our application, and the swift run command ran the executable that was built with the previous command. Most of the code in this book doesn't need the package manager to run, and it may be easier to simply use the compiler. Just keep in mind that for anything larger than a simple example, you will want to use the package manager or Xcode.
Next, let's see how to use the Swift compiler.