[PITCH] Make .tar.gz binaries available on MacOS

This pitch isn’t about altering the swift language. It’s about changing the way swift is available on MacOS. Forgive me, if this is not the right place to post this.

The swift download options at https://swift.org/download/ point to xcode download or the toolchain option downloads a .pkg file. However, the .pkg installer installs swift in some specific directory. The only customizable option is to be able to choose whether to install it for the user or globally.

I would like to have the flexibility to install swift in any location and be able to use it by changing the path variable. And I think this would be possible with .tar.gz downloads for MacOS. Do any such builds already exist? If so, how do I get them?

If not then is it possible to make .tar.gz swift builds available for MacOS on the downloads page? Just like .tar.gz files are available for Ubuntu.

1 Like

But why tar.gz? We have working zip support in macOS and don't need the tar step...

I think that would be better.

The Swift downloads page provides Xcode toolchains for macOS, so I don't quite understand what you mean by having the flexibility to install to an arbitrary location. How are you planning to make this work with Xcode?

You can do this with the existing .pkg files fairly easily:

`curl -o snapshot.pkg #{_SWIFT_ORG_URL}/#{version}/#{version}-#{platform}.pkg`
`pkgutil --expand snapshot.pkg snapshot`
`tar xf snapshot/#{version}-#{platform}-package.pkg/Payload`
puts `./usr/bin/swiftc --version`
3 Likes

Have you tried using swiftenv? It's really good.

I've only tried it in Linux, and it's awesome. Terminal-level wizardry. I'm sure that it's good for MacOS as well.

Fwiw, these are things you can do:

  • Install official builds of Swift
  • Install official development snapshots of Swift
  • Change the global toolchain that's used when running swift commands
  • Change the local toolchain (the one that's used in the current directory)
  • Uninstall toolchains
  • Build'em
  • And probably many more that I'm forgetting atm. It's very nice tho!
1 Like

I have tried it. And it's awesome.

2 Likes

Thanks! I will try this out.

I have tried doing something similar here. For some reason it worked till swift 4.0.3 but the REPL isn't working with swift 4.1!

I don't intend to make it work with Xcode. Xcode comes with swift bundled with it. Swift should be available for use with and without Xcode.

I want to be able to install multiple versions of swift which have nothing to do with the xcode version. Then, I can have isolated swift server side projects which don't interfere with iOS Development environment. And I want this without having to deal with xcode-select because that changes the global swift version.

1 Like

I think that's a bug they are working on at SR-7388. I hope they fix it soon. In the meantime, there are some flags and env. variables you can set up before running the REPL that should help you (details in the discussion).

I think SR-7388 is a linux only issue. While the problem I am facing is Mac specific.

I have not tested the same on linux yet. I will do so now.

I'm not sure I'd call this "fairly easily"! :-) @mishal_shah, this sounds like a reasonable request to me for those who don't care about Xcode integration. Should @ankit_goel file a bug?

FWIW, though, you can have more than one toolchain installed in the standard locations for Xcode, and differentiate them with xcrun -toolchain <org.swift.whatever> swiftc.

Fairly easy once you know the incantation, I suppose. :woman_mage:

2 Likes

build-script creates .tar.gz and our code signing system converts it into signed .pkg. I will need to look into how we want to handle code signing .tar.gz for macOS.

1 Like

Let me know if I need to file a bug. I would be happy to file one. @mishal_shah @jrose

As @anon27714269 pointed out, zip files are supported in MacOS. Maybe zip files are a better alternative. Zip/tar.gz whichever works with code signing.

Zip files do not have the ability to store file permissions, which is why they are not used to distribute software packages that rely on those permissions.

I also disagree that zip would be advantageous even if it supported permissions, .tar.gz archives are better integrated with unix environments and allow to change compression algorithms without hassle (.tar.bz/.tar.xz).

3 Likes

I tried this approach. It works but unfortunately the REPL doesn't work in this case.

Why do we need code signing for .tar.gz binaries? Can we not provide a signature to verify the download similar to what we do on Ubuntu?