Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I make a local module with the Swift Package manager?

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.

like image 670
taylor swift Avatar asked Nov 23 '16 23:11

taylor swift


People also ask

How do I add a local package to a project in Swift?

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.

How do I use Swift package manager with private repository?

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).

How do I import a local Swift package to Xcode project?

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.


1 Answers

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.

like image 80
rounak Avatar answered Oct 11 '22 23:10

rounak