How to use Swift Package Manager
What is Swift Package?
According to Apple’s doc:
For developers,
Swift Package
has the native support from Apple, which is recommended way of using 3rd libraries.
How to use
Go to File
→ 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 UITesting
.
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.
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.
Reference
Originally published at https://needone.app on October 30, 2020.