[swift-build-dev] Support installing SwiftPM executables from remote repos

David Hart david at hartbit.com
Thu Sep 14 13:21:29 CDT 2017


Hi Orta,

I’m also very interested in that topic, and I have some info which might interest you:

I have been working on similar functionality, but at the local level (npm install danger & npm run danger). Part of the work I did was integrated in the Swift Package Manager for Swift 4 and the rest will probably get released with the next point release (i.e., Swift 4.1).

For the sake of demonstration, lets imagine we’re already using Swift 4.1. You can add danger-swift as a dependency in a Package.swift - you can even use an empty Package.swift:

// swift-tools-version:4.0
import PackageDescription

let package = Package(
    name: "MyProject",
    dependencies: [
        .package(url: "https://github.com/danger/danger-swift.git", from: "1.0.0")
    ])

Then, you can run danger with:

$ swift run danger

As of Swift 4, swift run will only work for executable products defined in the current Package. But that will change in the next release.

Now, concerning global installation, I know that the Swift Package Manager team have already thought a lot about it, so it might be interested to see what they had in mind.

Regards,
David.

> On 14 Sep 2017, at 19:15, Orta Therox via swift-build-dev <swift-build-dev at swift.org> wrote:
> 
> Hey all,
> 
> I've been working on a SwiftPM executable (danger-swift <https://github.com/danger/danger-swift>) which is a pretty small CLI tool. I feel like it's a bunch of work to allow a user to get a copy of the app running on their computer / CIs. My current app distributions options are: Homebrew <https://brew.sh/> and Marathon <https://github.com/JohnSundell/Marathon> (which I added to homebrew) or a custom cURL'd setup script. None are great, because it requires many build steps and require custom installers. 
> 
> In an eco-system like Node/Ruby I can do something like "npm install -g danger" which uses the centralized index, or  "npm install -g danger/danger-js" if I wanted to use a repo which would install CLI tools. I'd like to see SwiftPM cover this part of the swift ecosystem, and encourage building small CLI tools in swift.
> 
> So, as an example of behavior, running this new command: "swift install danger/danger-swift" would:
> 
> - use the danger/danger-swift a shortcut for GitHub, and clone that repo into a temporary folder
> - parse the Package.swift <https://github.com/danger/danger-swift/blob/master/Package.swift> then let the user know they are going to install the CLI executable danger-swift
> - run swift build in release mode
> - install the executable into a folder in the users default path
> 
> This greatly reduces the friction to making more tools, and reduces the number of dependencies for users to being the Xcode CLT which basically everyone has out of the box.
> 
> I'm willing to take a stab at an implementation if this has approval of Anders/Daniel.
> 
> -- 
> [A.]	      Orta Therox
>> w/ Artsy <http://artsy.net/>
>> CocoaPods <http://cocoapods.org/> / CocoaDocs <http://cocoadocs.org/>
>> @orta <> / orta.github.com <http://orta.github.com/>
>> 
> 
> 
> _______________________________________________
> swift-build-dev mailing list
> swift-build-dev at swift.org
> https://lists.swift.org/mailman/listinfo/swift-build-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-build-dev/attachments/20170914/89090a36/attachment.html>


More information about the swift-build-dev mailing list