As it is, adding dependencies to your project is a bit of a pain. You go to the dependencies repo, copy the Git URL, check to see what the latest version is, go back to your project, add the dependency to your manifests dependencies array, run swift package update, generate an Xcode project or try to build, realize you forgot to add the dependency to your target(s), add it to the target(s), regenerate your Xcode project (if it applies),
and now it works! To sum it up, it requires too much back-and-forth work.
I think it would make sense to have an install command that works similarly to Go:
go get github.com/user/repo
swift package install github.com/user/repo
This would add the dependency to the manifest and one or more of its products to any of the project's targets.
The hard part about this command would seem to be helping the user determine which version requirement they should use. I see two parts to this problem:
Discovering which available versions are compatible with their package manifest (maybe none)
Offering available levels of version specificity to the user. Do they want to restrict to this major release? Maybe just this minor release or even the exact release? What is the default?
We could use the latest git tag, if none is provided, have a --branch <branch> flag if you want to just pick HEAD of a given branch, and have an @<tag> suffix on package names if you want a specific tag?
If that is the latest compatible git tag, I'd support it +1.
There's obviously a lot more you could do in the way of some user-interaction (providing a list of available options, etc). But I think that's better handled by convenience CLIs anyway.
This would be a great addition to the Swift Package Manager.
Personally I would slightly favour add as command. Though perhaps install is more common amongst package managers.
Being able to use something like ...
$ swift package add github.com/foo/bar@1.0.0 -t TargetName
... would be a real time saver. This would add the Bar dependency (version 1.0.0 specifically) only to the target named TargetName.
Discussion continued in SwiftPM slack and it quickly became apparent that this inability to easily install packages is a symptom of a much bigger problem with the Package.swift manifest.
I am going to be "That Guy" and reply to a 6 year old post. I had run across this thread when researching how to add/edit packages in Xcode projects through the command line. My main need was to quickly toggle package from/to local/remote and to spin up projects quickly with multiple packages without touching Xcode's GUI. Since this is still not possible and it seems to be difficult to add to the package manager I went ahead and created a command line tool that allows me to manage packages with a JSON file (or CSV file for simpler projects). With the tool I can toggle multiple packages from remote to local and back with one command. Wanted to share here in case it helps anyone. Still hoping for SPM to support this natively in the future. Here is my tool: clspm