My notes on using swift-package-manager in swiftui
Setup:
- XCode -> File -> new package -> (create a new package in the root of your app folder)
- XCode -> File -> add depedency pacakge -> press add local pacakge -> pick the new package
- import YourNewPackage in files you need access to pacakge code
- make things public to make the api available outside the package
Example:
Package:
public struct DatabaseLib {
//
public static func testing() {
Swift.print("testing")
}
}
Using the package:
import DatabaseLib
DatabaseLib.testing() // testing
Gotchas
- XCode seems a bit unstable when opening new packages. Sometimes it requires closing xcode and dragging the package onto the xcode icon again to open it isolated.