Adding confetti using Swift packages
A Swift package is pre-built software that we can use in any of our projects, in which all the coding work has been done for us; all we have to do is configure it in our project.
To add a Swift package, in Xcode, go to the File menu and select Add Packages…:
Figure 14.11: Add Packages…
In the All Sources window, enter https://github.com/simibac/ConfettiSwiftUI.git in the search box:
Figure 14.12: Adding the URL
When the Add Package button is clicked, Xcode will add the Confetti package to the project. The Confetti package contains all the code needed to create all kinds of confetti, dispersed in different ways.
Now, we need to import the Confetti framework into the ContentView
file at the top:
import ConfettiSwiftUI
Next, we need a variable that can trigger the confetti (placed after the other project variables):
//confetti variable @State var...