Search code examples
swiftxcodeswift-package-manager

Swift Package Manager For Development


Question: Is there a way to create a "development package" with SPM similar to a development pod in cocoa pods that will let me make changes to the actual source project of a dependency package (local path)?

Context: I'm working on a project that needs to be split into three separate projects. One of these projects is shared by the other two (in this case a data model, shared by a server and a client). For the client, as it uses uikit, I have a development cocoa pod setup that lets me work within the client workspace, make edits to the data model project, and then immediately compile and run. My changes to the data model are then saved in the data model project.

However, for the server, as it is entirely built with SPM, if I want to make edits to the data model project (which I want to have reflected to the client), I currently have to make them in the data model project, then retag it with a new minor version number, clean the server project, and rebuild. I'd love to just set this up like I do with cocoa pods.

If I can't do that, is there at least a way to tell SPM to only update one of my dependencies to a new version number (or to the max version as specitifed within the Package.swift. i.e. minor version of .4, so if I retag from .401 to .402 it would update)? I would have thought I could do this in the Package.pins, but that doesn't seem to work. Not sure why it's not a hidden file if editing it doesn't effect actual changes.


Solution

  • The concept you call "development package" is called Editable Package in Swift Package Manager:

    For the packages which are in the editable state, swift build will always use the exact sources in this directory to build, regardless of its state, git repository status, tags, or the tag desired by dependency resolution. In other words, this will just build against the sources that are present.