SwiftFiddle/swift-ast-explorer

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

Closed this issue · 4 comments

To run from Xcode, add build settings to link lib_InternalSwiftSyntaxParser.dylib explicitly.

See

SwiftSyntax depends on the lib_InternalSwiftSyntaxParser.dylib/.so library which provides a C interface to the underlying Swift C++ parser. When you do swift build SwiftSyntax links and uses the library included in the Swift toolchain. If you are building an application make sure to embed _InternalSwiftSyntaxParser as part of your application's libraries.

You can either copy lib_InternalSwiftSyntaxParser.dylib/.so directly from the toolchain or even build it yourself from the Swift repository, as long as you are matching the same tags or branches in both the SwiftSyntax and Swift repositories. To build it for the host os (macOS/linux) use the following steps:

https://github.com/apple/swift-syntax#embedding-swiftsyntax-in-an-application

So, the easy way is launching the app from command line swift run

@kishikawakatsumi Thanks

I clone swift-ast-explorer code at my computer,don't find .xcodeproj file
As shown in figure

image

then open Package.swift with xcode

image

it can't add build settings to link lib_InternalSwiftSyntaxParser.dylib explicitly.

So, the easy way is launching the app from command line swift run
@kishikawakatsumi I know this way

but i want to debug swift-ast-explorer project

This is a Swift PM managed project. No xcodeproj by default. You can generate xcodeproj by swift package generate-xcodeproj