How to find out if a SPM package is in edit mode

hi folks,

the design of the "override" feature is wip and once a bit more mature will be shared with the community as part of a typical evolution process. rest assured we would not deprecate edit/unedit until an adequate replacement is in place. the point in my reply to @adam-fowler's original question was that it may not be worth investing heavily in supporting this feature (presumably for the vscode plugin?) if it will be changed in the near-ish future.


very high level design thoughts (cc @NeoNacho)

atm "edit mode" is actually two different features: you can trigger it from the CLI (which is what the OP is asking about) in which case it is managed as an internal state in SwiftPM, while Xcode has a different way of achieving "edit mode" documented in Apple Developer Documentation, which is not always reliable given reliance on weak identity derived from the path and the manifest name which cannot be 100% unique.

to unify these into a single reliable feature, we have been considering an explicit override file (somewhat similar to the mirrors file, and potentially superseding it) where you can point a package by its unique identity to a location on disk where its being edited, e.g.:

{
    "swift-nio": {
        type: "fileSystem",
        path: "/Users/tomerd/code/swift/swift-nio"
    }
}

this means you do not need to make changes to the manifest file in order to edit the package locally and you can easily switch from edit/non-edit mode. we can of course also add sugar in the shape of edit/unedit commands from the CLI but they may behave a bit differently from the ones we have today.

this can also allow users to do other types of overrides, such as what is possible today in mirrors:

{
    "swift-nio": {
        type: "sourceControl",
        url: "http://github.com/tomerd/my-swift-nio-fork"
    }
}

and once registry support is in place, do the same for remapping identities in enterprise registries:

{
    "swift-nio": {
        type: "registry",
        identity: "swift-nio-internal-testing"
    }
}

as mentioned above these are preliminary thoughts, and once a bit more mature will be shared with the community as part of a typical evolution process. rest assured we would not deprecate edit/unedit until an adequate replacement is in place.

7 Likes