I know the Swift package manager can compile code from github as a module for my project, but can I tell the package manager to compile code that is stored locally on my computer instead?
The idea is I have some code that I want to separate off from the rest of my project, so I keep it in a folder and the Swift compiler will build it so that that code can be imported like any other module.
Open your Xcode project and create a local Swift package as part of your project by selecting File > New > Swift Package. Choose a project and a group, but don't create a new Git repository if your app is already under version control; then create the new Swift package.
The process is straight: create a private repo with SPM package on one of the hostings above. Then add it as a dependency in your Xcode project as a usual package. Since the repo is private, Xcode will ask for credentials (in case of Gitlab it's an access token which you can generate in your Gitlab account).
Open your app's Xcode project or workspace. Select the Swift package's folder in Finder and drag it into the Project navigator. This action adds your dependency's Swift package as a local package to your project.
You can also use
.package(path: "path to folder")
if you don't want the overhead of an additional git repo. This can even be a relative path.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With