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

Mint support? #1038

Closed
BrentMifsud opened this issue Mar 15, 2022 · 13 comments
Closed

Mint support? #1038

BrentMifsud opened this issue Mar 15, 2022 · 13 comments

Comments

@BrentMifsud
Copy link

I get a long list of these errors:

error: Unable to parse /Users/brent/Developer/<My Project>/path/to/source/file/MySourceFile.swift, error The loaded '_InternalSwiftSyntaxParser' library is from a toolchain that is not compatible with this version of SwiftSyntax
@BrentMifsud BrentMifsud changed the title Sorcery failing to run in Xcode 13.3 Sourcery failing to run in Xcode 13.3 Mar 15, 2022
@maxim-chipeev
Copy link

By any chance are you using Mint to run Sourcery?

Facing same issue

@BrentMifsud
Copy link
Author

BrentMifsud commented Mar 15, 2022

yep using mint

Unfortunately we don't use cocoapods anymore. And Homebrew doesn't allow for you to download specific versions of apps. So mint is really our only option until swift package build tools are supported.

@kvacquier
Copy link

We've got the same issue using the cocoapods version (updated)

@alvaroblazmon
Copy link

I know that it's not the best solution but I downgraded the version to 1.0.2 using Mint and it works with Xcode 13.3

@krzysztofzablocki
Copy link
Owner

Mint is not supported because we need stable rPath

@kvacquier you got linker issue with dylib with cocoapods? Do you have logs? That shouldn't happen

@krzysztofzablocki krzysztofzablocki changed the title Sourcery failing to run in Xcode 13.3 Mint support? Mar 17, 2022
@AF-cgi
Copy link

AF-cgi commented Mar 18, 2022

I use Sourcery via Mint and it works perfect. But the current issue is the usage of the wrong SwiftSyntax version. For Xcode 13.3 Apple has released a new version. See here: https://github.com/apple/swift-syntax/releases/tag/0.50600.1. Also look to this PR #1037.

@liamnichols
Copy link
Collaborator

I use Sourcery via Mint and it works perfect

The Sourcery binary produced using swift build or mint run won’t work if it’s built with the wrong version of Xcode, or if the version of Xcode used to build it is relocated/deleted from disk.

If I understand correctly, updating Sourcery to support parsing of Swift 5.6 syntax in files (which would require using the newer SwiftSyntax library) is slightly different to this issue of which version of the Swift toolchain should be used to build the project

@liamnichols
Copy link
Collaborator

liamnichols commented Mar 18, 2022

That being said, since the patch in #1037 avoids spm/mint from linking to the lib_internalSwiftSyntaxParser.dylib located in the toolchain of the version of Xcode that you use to build the binary, you could actually build sourcery using Xcode 13.3 on that branch and it'll work while still using SwiftSyntax 0.50500.0:

$ mint run liamnichols/Sourcery@bddbeb5

@AF-cgi
Copy link

AF-cgi commented Mar 21, 2022

@liamnichols That's right, but 0.50500.0 is the wrong version for using Xcode 13.3. The 0.50500.0 is the right version to built Sourcery with Xcode 13.0 ..< 13.3. For Xcode 13.3 you should use 0.50600.1. Look here: https://github.com/apple/swift-syntax. SwiftLint did this fix in his release 0.47.0-rc.4.

@liamnichols
Copy link
Collaborator

0.50500.0 is the right version to built Sourcery with Xcode 13.0 ..< 13.3. For Xcode 13.3 you should use 0.50600.1. Look here: https://github.com/apple/swift-syntax. SwiftLint did this fix in his release 0.47.0-rc.4.

Yeah, I'm not 100% sure here but my understanding of that table is that the "Xcode Release" column is just describing with version of Xcode ships with the default toolchain for that version of Swift and since we can still build SwiftSyntax 0.50500.0 with Xcode 13.3/Swift 5.6 (as long as we still link to the 0.50500.0 version of lib_InternalSwiftSyntaxParser), it shouldn't be an issue.

It would be great to use SwiftSyntax 0.50600.1 at some point though, but that also means that the minimum requirements for building Sourcery become Xcode 13.3 which I am not sure if we do or don't want to do. For example, SwiftLint has conditions in Package.swift to support both. I'm not sure which route we want to go down, but happy to work towards it given some guidance.

I'll drop some notes based on ☝️ in my PR

@liamnichols
Copy link
Collaborator

Sorry, to clarify actually because I was kind of wrong..

The version of Xcode Release in the table is important when you rely on it to link to the correct version of lib_InternalSwiftSyntaxParser.dylib which is located at Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/lib_InternalSwiftSyntaxParser.dylib. If you used Xcode 13.3 to swift build/mint run, it would dynamically link to lib_InternalSwiftSyntaxParser.dylib for 0.50600.1, since that is what ships with that version of Xcode.

But in the case of #1037, that does not happen/is not a problem because instead we use a separate version of the library that is linked statically

@krzysztofzablocki
Copy link
Owner

krzysztofzablocki commented Mar 21, 2022

the problem with Mint is simply the fact it skips my manual re-write of rPath and as such doesn't use the lib version I bundled with the binary in normal Cocoapods / Brew releases, it looks at your Xcode version which can be incompatibile. Static linking will fix all of it

@krzysztofzablocki
Copy link
Owner

fixed on main by #1037

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

7 participants