NSHipster / SwiftSyntaxHighlighter

A syntax highlighter for Swift code that uses SwiftSyntax to generate Pygments-compatible HTML.
https://nshipster.com/swiftsyntax/
MIT License
276 stars 12 forks source link

dyld: Library not loaded: @rpath/lib_InternalSwiftSyntaxParser.dylib #3

Closed bonyadmitr closed 3 years ago

bonyadmitr commented 4 years ago

Added SwiftSyntaxHighlighter using SPM in new macOS project and got error:

dyld: Library not loaded: @rpath/lib_InternalSwiftSyntaxParser.dylib
  Referenced from: {USER_FOLDER}/Library/Developer/Xcode/DerivedData/SwiftSyntaxMac-dcedkjjsloqegmatufrxjfbzzxub/Build/Products/Debug/SwiftSyntaxMac.app/Contents/MacOS/SwiftSyntaxMac
  Reason: image not found

Also found similar problems in other projects: https://github.com/realm/SwiftLint/issues/3105 https://github.com/uber/mockolo/issues/108

Couldn't find solution.

Xcode Version 11.4.1 (11E503a)

bonyadmitr commented 4 years ago

i've found doc description: https://github.com/apple/swift-syntax#embedding-swiftsyntax-in-an-application

mattt commented 4 years ago

Added SwiftSyntaxHighlighter using SPM in new macOS project and got error:

When do you get this error? Is it when you try building and running your package executable with Xcode?

bonyadmitr commented 4 years ago

Added SwiftSyntaxHighlighter using SPM in new macOS project and got error:

When do you get this error? Is it when you try building and running your package executable with Xcode?

yes, on running with Xcode.

mattt commented 4 years ago

@bonyadmitr Thanks for confirming. This looks like the same issue as https://github.com/SwiftDocOrg/SwiftSemantics/issues/2:

Until a better solution is provided upstream, my suggestion would be to run swift package generate-xcodeproj to generate an Xcode project and then xed <#Package#>.xcodeproj to open the generated project directly.

bonyadmitr commented 4 years ago

@bonyadmitr Thanks for confirming. This looks like the same issue as SwiftDocOrg/SwiftSemantics#2:

Until a better solution is provided upstream, my suggestion would be to run swift package generate-xcodeproj to generate an Xcode project and then xed <#Package#>.xcodeproj to open the generated project directly.

yea, seems the same.

maybe it should be fixed by doc link: https://github.com/apple/swift-syntax#embedding-swiftsyntax-in-an-application

i tried it but couldn't build it yourself from the Swift repository,. i got build-parser-lib script error.

and thanks for answer!

mattt commented 3 years ago

I was able to get this working in Xcode 12.5 using the latest OSS Toolchain. I just updated the README with details about how to do this with 72f1496.