You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -110,20 +82,12 @@ Running `swift build` will instruct SwiftPM to download the new dependencies and
110
82
Running this command also created a new file for us, `Package.resolved`.
111
83
This file is a snapshot of the exact versions of the dependencies we are using locally.
112
84
113
-
To use this dependency, we can open `MyCLI.swift`, remove everything that’s in there (it’s just an example), and add this line to it:
114
-
115
-
~~~swift
116
-
importFiglet
117
-
~~~
118
-
119
-
This line means that we can now use the `Figlet` module that the `example-package-figlet` package exports.
120
-
121
85
## A small application
122
86
123
-
Now let’s write a small application with our new dependency. In our `MyCLI.swift`, add the following code:
87
+
Start by removing `main.swift`. We’ll replace it with a new file called `MyCLI.swift`. Add the following code to it:
124
88
125
89
~~~swift
126
-
importFiglet// from the previous step
90
+
importFiglet
127
91
128
92
@main
129
93
structFigletTool {
@@ -133,15 +97,9 @@ struct FigletTool {
133
97
}
134
98
~~~
135
99
136
-
Now lets remove the default unit test since we changes the tools' code.
137
-
Replace the example content of `MyCLITests.swift` with the following code:
100
+
This provides a new entrypoint to the app which could be asynchronous if required. You can either have a `main.swift` file or a `@main` entrypoint, but not both.
138
101
139
-
~~~swift
140
-
@testableimportMyCLI
141
-
importXCTest
142
-
143
-
finalclassMyCLITests: XCTestCase {}
144
-
~~~
102
+
With `import Figlet` we can now use the `Figlet` module that the `example-package-figlet` package exports.
145
103
146
104
Once we save that, we can run our application with `swift run`
147
105
Assuming everything went well, you should see your application print this to the screen:
@@ -164,40 +122,36 @@ To add this capability to our application, we add a dependency on [swift-argumen
164
122
To do so, we extend our `Package.swift` file with the following information:
165
123
166
124
~~~swift
167
-
// swift-tools-version: 5.7
125
+
// swift-tools-version: 5.8
126
+
// The swift-tools-version declares the minimum version of Swift required to build this package.
0 commit comments