Can I use a SwiftPM package off the local filesystem without making a separate git repository for it?

Our company follows a "mono-repo" style of source control - at least for our mobile apps. We currently have 6, all in a single git repository, with folders for shared code etc.

We have a couple of libraries (all swift) which are used across multiple apps, and currently we use a mixture of direct file inclusion, or local XCFrameworks to enable code sharing. XCFrameworks are unwieldy and difficult to configure correctly, and it seems like a SwiftPM package would be a perfect fit for this use-case (particularly given that in some situations I want a static library rather than a dynamically loaded one)

I've experimented and I know that I can take some shared code, create a SwiftPM package for it, and include that in each Xcode project for each app. It works very well - BUT SwiftPM (or at least the Xcode integration) seems to require that each SwiftPM project lives in the root of it's own Git repository.

I explicitly do not want a whole load of git repositories for each package; The monorepo model is working very well for us and I don't want to break our whole team's workflow on account of SwiftPM. Somewhat related as well is we have other teams who are not using git, and they might like to use some SwiftPM packages in future as well.

Is it possible to simply reference a Package from the filesystem, and have SwiftPM forgo all its git integration requirements? The Package.swift is sitting right there, after all.
If not, how might I go about requesting that as an enhancement for future versions of SwiftPM?

Just use one of the dependency specifiers with a path parameter instead of one with a url parameter.

In Xcode, you can also drag the root directory of a package (the one which contains Package.swift) from Finder into Xcode’s file list on the left. The Xcode project will include the package by referring to it with a relative path.

Thanks! I feel silly for missing that, but I googled a lot and couldn't find it. Hopefully this is useful for other devs in future

1 Like
Terms of Service

Privacy Policy

Cookie Policy