Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SWIFT_VERSION breaks Carthage build #145

Closed
JonasVautherin opened this issue Jan 16, 2019 · 5 comments
Closed

SWIFT_VERSION breaks Carthage build #145

JonasVautherin opened this issue Jan 16, 2019 · 5 comments

Comments

@JonasVautherin
Copy link

I am not completely sure, but it seems to me that Xcode sets SWIFT_VERSION in a way that is incompatible with swiftenv.

Say I have Swift 4.2.1 installed on my system, and I don't have Swift 4.2. Xcode doesn't care, and calls it 4.2. And it sets SWIFT_VERSION = "4.2".

Now, swiftenv reads SWIFT_VERSION (that apparently overrides .swiftenv) and tries to run with Swift 4.2 instead of 4.2.1.

It results in the following error:

swiftenv: version `4.2' (set by SWIFT_VERSION environment variable) is not installed
no such command: swift

More specifically, this means that I can build manually from Xcode, but Carthage fails to build my project. Like if Carthage was using swiftenv, but Xcode didn't care and went directly to its own Swift binary.

Uninstalling swiftenv fixed my issue.

Would there be a way to somehow improve this behavior?

@davisford
Copy link

I don't think swiftenv works with Carthage at all. The latter appears to completely ignore the former.

If I run

$ swift --version
Apple Swift version 4.2.1 (swift-4.2.1-RELEASE)

...which is set by .swiftenv but then run carthage bootstrap --platform iOS it still uses the default 5.0:

***  Skipped installing ios-snapshot-test-case.framework binary due to the error:
	"Incompatible Swift version - framework was built with 4.2.1 (swiftlang-1000.11.42 clang-1000.11.45.1) and the local version is 5.0 (swiftlang-1001.0.69.5 clang-1001.0.46.3)."

@JonasVautherin
Copy link
Author

But then I don't really get how I was getting the error mentioned above 🤔... And that's unfortunate, because it would actually be practical to use swiftenv with Carthage, right? 😅.

@davisford
Copy link

Who / what sets the SWIFT_VERSION environment variable?

@kylef
Copy link
Owner

kylef commented Apr 21, 2019

I am not completely sure, but it seems to me that Xcode sets SWIFT_VERSION in a way that is incompatible with swiftenv.

The Xcode build configuration SWFIT_VERSION is different to the environmental variable SWIFT_VERSION and I think this is unrelated.

But then I don't really get how I was getting the error mentioned above 🤔... And that's unfortunate, because it would actually be practical to use swiftenv with Carthage, right? 😅.

If I understand correctly, Carthage is an Xcode tool which uses the Xcode build system. swiftenv manages the swift version for the swift CLI which is outside Xcode. Perhaps depending on how the system is configured swiftenv shims could be set to be used in Xcode, not sure if this is possible. Been a while since I last used Xcode but I don't think it picks up on shell configuration (at least for me with fish).

Who / what sets the SWIFT_VERSION environment variable?

The end user usually. Setting the SWIFT_VERSION environmental variable allows users to set the version of swift tools that the swiftenv shims use. swiftenv allows you to use a .swift-version file too, this should be explained in https://swiftenv.fuller.li/en/latest/getting-started.html#switching-swift-versions, the SWIFT_VERSION environemntal variable can be used to tempoarily override those selected versions,

@JonasVautherin
Copy link
Author

Not sure where that is going, and I stopped using swiftenv because it doesn't seem to apply to Carthage (anymore?). Thanks for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants