Now that the module has been created, let's look at how we would use it in a project. The first thing we will need to do is to create a new project. The following commands will set up a new project named pcapProject
:
mkdir pcapProject cd pcapProject swift package init
Now that the directory structure for our project has been created, we need to tell the compiler to use the newly created Cpcap
module. To do this, we will need to add a dependency to the Package.swift
file. The following code will define our application and also its dependency on the Cpcap
module:
import PackageDescription let package = Package( name: "pcapProject", dependencies: [.Package(url: "../Cpcap", majorVersion: 0, minor: 1)] )
We add the dependency using the dependencies
line. The url
within the dependencies line defines the path to the module. This can be the filesystem path, as shown in our example, or an Internet URL to a GitHub repository....