Code Monkey home page Code Monkey logo

Comments (14)

nrudnyk avatar nrudnyk commented on May 20, 2024 3

the current error is your second one, about swift-format mismatch, I think it's related to image

I'm on Ventura, so I can't run Xcode13, I've tried to use the lib_InternalSwiftSyntaxParser.dylib from xcode13, but that didn't helped :(

@wambambizzle as per that screenshot, I've built library locally using latest main branch, which worked (instead of trying to match exact versions)

@maticzav this might be a viable solution, maybe you'd like me to create pull request?

from swift-graphql.

nordfogel avatar nordfogel commented on May 20, 2024 3

@wambambizzle, @nrudnyk , @maticzav:
same unpleasing experience for us

  • Xcode 14.0.1
  • swift tools version 5.7
  • swift-graphql 4.0.0

the described and reproducible issue reported by @nrudnyk regarding code generation seems to be caused by the hard swift-format dependency within the Package.swift

dependencies: [
        // .package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
        .package(url: "https://github.com/apple/swift-argument-parser", from: "1.0.0"),
        .package(url: "https://github.com/apple/swift-format", from: "0.50600.1"),
        // ... 

As the dev team from swift-format points out here (see screenshot from @nrudnyk above) this specific version is bind to Xcode 13.3 and swift tools version 5.6.

Current workaround

Therefore my current workaround which does the trick has been the following so far:

  1. clone the swift-graphql repository
  2. modify the Package.swift file in line 28 to
        .package(url: "https://github.com/apple/swift-format", branch: "main"),
  1. build the swift-graphql executable via make install
  2. copy the executable from .build/release/swift-graphql to our current project
  3. run e.g. `swift-graphql <your.respective.url>/graphql --output ./Sources/Generated/API.swift --header "Authorization: Basic AXVubzpwQDU1dzByYM=="
  4. Voila 🎉 smooth sailing
Generating SwiftGraphQL Selection 🚀
Adding headers to your request:
 - Authorization: Basic AXVubzpwQDU1dzByYM==
✔ Schema loaded!         
✔ API generated successfully!
⠙ Analyzing Schema
  1. fix a couple of issues caused by the breaking changes introduced in 3.0.0 and 4.0.0 (coming from 2.3.0) 🙈

@maticzav: any chance to create a PR regarding the pointed version of swift-format as dependency used by the SwiftGraphQLCodegen library which is a dependency of the SwiftGraphQLCLI executable?

An additional comment on this topic

Related to the note in the contribution guidelines

Due to a major improvement in swift-format Source:

NOTE: swift-format on the main branch now uses a version of SwiftSyntax whose parser has been rewritten in Swift and no longer has dependencies on libraries in the Swift toolchain. This allows swift-format to be built, developed, and run using any version of Swift that can compile it, decoupling it from the version that supported a particular syntax.

makes the described requirement and the currently used fix version of swift-format obsolete.

from swift-graphql.

wambambizzle avatar wambambizzle commented on May 20, 2024

Update:

I've managed to get past the above error by copying over the executable from the swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/lib_InternalSwiftSyntaxParser.dylib and placing it into the swift-5.5 folder and down grading my code gen cli to 3.0.2. But I'm still running into an issue when trying to use the code gen

swift-graphql https://your-api-here --config swiftgraphql.yml -o Schema.swift
Generating SwiftGraphQL Selection 🚀
✔ Schema loaded!
✖ The operation couldn’t be completed. (SwiftSyntaxParser.ParserError error 1.)
Error: There was an error formatting the code. Make sure your Swift version (i.e. `swift-format`) matches the `swift-format` version. If you need any help, don't hesitate to open an issue and include the log above!

Re downloaded Xcode 13.4.1 (https://developer.apple.com/download/all/?q=xcode%2013.4). Recopied the parser.dylib file into swift-5.5/macosx and the code gen worked. Seems that Xcode 13 utilizes swift 5.5 and Xcode 14 used 5.6/7. This was were the swift versioning issues was coming from

from swift-graphql.

nrudnyk avatar nrudnyk commented on May 20, 2024

@wambambizzle @maticzav
some other libs faced this issue, for example Needle

hopefully this can be resolved

from swift-graphql.

nrudnyk avatar nrudnyk commented on May 20, 2024

Recopied the parser.dylib file into swift-5.5/macosx and the code gen worked. Seems that Xcode 13 utilizes swift 5.5 and Xcode 14 used 5.6/7. This was were the swift versioning issues was coming from

@wambambizzle what do you mean by recopied, could you please be more specific? thanks!

from swift-graphql.

wambambizzle avatar wambambizzle commented on May 20, 2024

Sorry, I just meant "copied" !

from swift-graphql.

nrudnyk avatar nrudnyk commented on May 20, 2024

@wambambizzle you've mentioned that you copied lib_InternalSwiftSyntaxParser.dylib from /Applications/Xcode.app into it's swift-5.5 folder. This step helped fixing first issue with missing parser.dylib.

Then appeared SwiftSyntaxParser.ParserError error. So you copied lib_InternalSwiftSyntaxParser.dylib from Xcode13 into swift-5.5/macosx Is that correct?

So both for the lib_InternalSwiftSyntaxParser.dylib libs are from Xcode 13 or some of them from Xcode14?

sorry for confusion, but I still can't get it working

from swift-graphql.

wambambizzle avatar wambambizzle commented on May 20, 2024

IIRC I copied it from the swift/Mac into swift-5.5/Mac and any other places that it was saying was missing.

Do you have the code gen cli installed locally via something like homebrew? And version of Xcode are you currently building against ? No need to apologize, I understand completely.

from swift-graphql.

nrudnyk avatar nrudnyk commented on May 20, 2024

@wambambizzle I've built it manually using make. At the moment I have Xcode14, which is released officially

from swift-graphql.

wambambizzle avatar wambambizzle commented on May 20, 2024

Do you still have Xcode 13.x installed by chance? I think part of the issue (besides needing to copy that lib into the other folders), is that Xcode 13.x is associated to Swift 5.5 while Xcode 14 is Swift 5.6/7. What is the current error(s) that you are seeing?

from swift-graphql.

nrudnyk avatar nrudnyk commented on May 20, 2024

the current error is your second one, about swift-format mismatch, I think it's related to
image

I'm on Ventura, so I can't run Xcode13, I've tried to use the lib_InternalSwiftSyntaxParser.dylib from xcode13, but that didn't helped :(

from swift-graphql.

wambambizzle avatar wambambizzle commented on May 20, 2024

You can't run it or you can't download/install it at all? If not, think you might have try and find a way to manually install Swift 5.5

from swift-graphql.

nrudnyk avatar nrudnyk commented on May 20, 2024

to be explicit, it's

✖ The operation couldn’t be completed. (SwiftSyntaxParser.ParserError error 1.)
Error: There was an error formatting the code. Make sure your Swift version (i.e. `swift-format`) matches the `swift-format` version. If you need any help, don't hesitate to open an issue and include the log above!

from swift-graphql.

maticzav avatar maticzav commented on May 20, 2024

hi everyone

excuse my silence, I see that you've made quite a bit of progress investigating the issue. I'd love to approve a PR if anyone has the capacity or pair program or even just chat with someone from this thread.

Let me know if anyone wants to help with this, I have capacity for the next two weeks 🙂

from swift-graphql.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.