What is Swift Package?
According to Apple's doc:
- Swift packages are reusable components of Swift, Objective-C, Objective-C++, C, or C++ code that developers can use in their projects. They bundle source files, binaries, and resources in a way that’s easy to use in your app’s project.
Swift Package has the native support from Apple, which is recommended way of using 3rd libraries.
How to use
Swift Package →
Add Package Dependency:
Add Swift Package URL:
Then it will ask you to confirm with the versions, keep it default.
Then it will prompt to ask for which target you want to use, in my case. Choose the main target in most of the time, but in my case it is
Then we are able to use the library. Sometimes we need to compile, build or run test to let the Xcode to recognize the libraries we just added.
Update and modify existing Swift package libraries
We can also update the library by selecting [Target] → Build Phrase → Link Binary With Libraries:
We can add and remove any Swift Package Library to any targets in the project.