Package.swift. This file defines your project name and the dependencies. It is created automatically once you create your project. Usually, you'll not do any changes to this file. Here are some quick overviews of this file:
privatein the code. They decide the access control of your class.
publicmeans any other parts could use it. In this code, like the class, the initializer, and the methods, they will be used to create code, so they are public.
privatemeans it could only be used inside the class. The properties
ledOnValueare used only in this class, so they are private.
DigitalOut. Then to make it more clear, you create a property
ledOnValueto store the value to turn on the LED,
false. For example, if you use the onboard LED, this value will be
selfis added to identify them.
self.pinrefers to the property
pinabove. When you pass values to the parameters, the values will be assigned to the two properties.
ledOnValuedefines the value to turn on a LED, you don't need to care about its value now and directly pass the value to the method
package.swift, you indicate the location of the library and its name in
dependenciesas the two highlight parts below. Paste the URL of the package and add its version.
main.swift, import the targets that are needed for your project. You could notice in the line2 that you import the
SwiftIOBoard. It is one of the targets of
MadBoards. The other two are the unique target in their library that shares the same name with the library.
Package.swiftwill be built first, then the IDE will automatically get the libraries from Github. So it will cost a while the first time you build it.