mise icon indicating copy to clipboard operation
mise copied to clipboard

Add Swift plugin

Open pepicrft opened this issue 1 year ago • 5 comments

I'm implementing a core plugin to manage Swift versions. As a follow-up work, I'll implement a backend to install community packages representing CLIs.

The current Swift asdf-plugin turns out to be using swiftenv under the hood installing it if absent in the environment using Homebrew (too much indirection).

pepicrft avatar Feb 24 '24 12:02 pepicrft

@pepicrft really sorry it took me so long to get around to this. It looks excellent though. I had some feedback that really is just nitpicks pretty much. The one thing we should get is an e2e test though, https://github.com/jdx/mise/blob/main/e2e/test_erlang is a good example of one you can use as a reference.

You can either just copy test_erlang over to test_swift and push changes here, you will need to ping me to approve the test to execute I think since I don't think you've contributed to mise directly yet but of course I'm happy to do that as often as you need. You can also run the e2e tests via docker, see https://mise.jdx.dev/contributing.html for instruction on that.

If you have any trouble with the e2e test I'd be happy to add that to your PR too.

jdx avatar Mar 16 '24 14:03 jdx

No worries @jdx. I appreciate your review of the PR. The implementation is still incomplete, so as soon as I finish it, I'll add an e2e test to ensure everything works as expected.

I have one question. Xcode installations come with a Swift toolchain embedded in the application bundle, which is the one used by default when that version of Xcode is selected via xcode-select. I was wondering if mise ls swift should include that version too. Maybe with a different formatting:

$ mise ls swift
  5.9.0
  5.10.0 (/Applications/Xcode.app)

If you agree, how do you think I should approach it from the Forge trait. I proposed here, but I'm not entirely convinced that's the best idea. In essence, some plugins would be able to provide an additional set of versions that are managed outside of Mise.

pepicrft avatar Apr 28 '24 18:04 pepicrft

Having recently gone through installing swift on linux, there's a couple of issues on different distributions it seems (primarily due to linking to native libraries). Have you been able to test this on multiple distributions?

For example, on arch the most popular package to install swift uses patchelf because the source swift distribution uses incorrect paths (at least for arch). Using https://github.com/swift-server/swiftly as an alternative, has similar issues where just running swift will cause some library not found errors.

I'm not very familiar with swift itself or the best way to resolve this across different distributions, but it would be great if it could accommodate them.

I know there are options when building swift to statically link its dependency libraries too, which might be another avenue to go down?

johnpyp avatar May 03 '24 21:05 johnpyp

Thanks @johnpyp! I haven't tested it yet in Linux distributions, but I'll make sure I do before considering the PR ready. What other contributions come to your mind?

pepicrft avatar May 04 '24 06:05 pepicrft

For Linux support, the Ubuntu 24.04 builds of Swift 5.10.1 work perfectly under Arch Linux without modification. The Ubuntu 24.04 builds don't seem to exist for all versions yet, but that might be a good option to use if they're available.

shassard avatar Jun 15 '24 13:06 shassard