Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

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

Closed
kean opened this issue Apr 7, 2020 · 12 comments
Closed

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

kean opened this issue Apr 7, 2020 · 12 comments

Comments

@kean
Copy link
Contributor

kean commented Apr 7, 2020

Environment

Xcode 11.4

Steps

  • Pull the latest swift-doc from master
  • Open Package.swift
  • Run swift-doc target or unit tests for SwiftDoc library

Observed result

dyld: Library not loaded: @rpath/lib_InternalSwiftSyntaxParser.dylib
Referenced from: /Users/kean/Library/Developer/Xcode/DerivedData/swift-doc-enlnpuwdeszizwbdykidcjodocbk/Build/Products/Debug/swift-doc
Reason: image not found

Related

realm/SwiftLint#3105

@mattt
Copy link
Contributor

mattt commented Apr 7, 2020

Also related to SwiftDocOrg/SwiftSemantics#2

@kean
Copy link
Contributor Author

kean commented Apr 7, 2020

Closing as duplicate.

@kean kean closed this as completed Apr 7, 2020
@mattt
Copy link
Contributor

mattt commented Apr 7, 2020

Actually, I think there's a SwiftDoc-specific action to be taken for this. Until this is resolved in a future version of Xcode, we should at least document this as a Known Issue (similar to what we're doing in SwiftSemantics except, well... less awkwardly-written).

@mattt mattt reopened this Apr 7, 2020
@kean
Copy link
Contributor Author

kean commented Apr 8, 2020

@mattt, do you know if there is a workaround?

@mattt
Copy link
Contributor

mattt commented Apr 8, 2020

@kean Last I checked, you can run swift package generate-xcodeproj to generate an Xcode project and then xed <#Package#>.xcodeproj to open the generated project directly.

@kean
Copy link
Contributor Author

kean commented Apr 8, 2020

It results in another issue on my machine.

Screen Shot 2020-04-08 at 12 25 19

@mattt
Copy link
Contributor

mattt commented Apr 8, 2020

😞 Woof. Thanks for giving that a try. Sorry that isn't a viable solution in the meantime. I'll work to get that documented as a known issue and keep an eye out for a long-term fix in Xcode.

@kean
Copy link
Contributor Author

kean commented Apr 8, 2020

Is there any way I can run the executable and/or unit tests with the debugger attached in Xcode?

@mattt
Copy link
Contributor

mattt commented Apr 8, 2020

Not that I know of, unfortunately. I've been getting by with Console.app crash logs and print statements as needed, but would definitely prefer a real debugging setup.

@kean
Copy link
Contributor Author

kean commented Apr 8, 2020

Apparently, the issue is that SwiftSyntax uses some private library named lib_InternalSwiftSyntaxParser.dylib. This library is not yet distributed as part of the OS (as of macOS 10.15.4). It is, however, available in Xcode 11.4:

/Applications/Xcode.app/Contents/Frameworks/lib_InternalSwiftSyntaxParser.dylib

So all you need to do is modify @​rpath to make sure that the library is there when swift-doc is executed. Unfortunately, there doesn't seem to be any way to do that using Swift Package Manager.

What you can do is change environment variables, like DYLD_LIBRARY_PATH, when running the tests. With this setting, I am now able to run SwiftDoc unit tests from Xcode with debugger attached.

Screen Shot 2020-04-08 at 15 33 08

Naturally, there are multiple ways to set environment variables. Another option is to add it to .bash_profile.

@JaapWijnen
Copy link
Contributor

JaapWijnen commented Jan 18, 2021

This doesn't work for me unfortunately. Any updates on how to fix this? Trying to run the swiftdoc tests on a local fork. (I'm also getting the redefinition of module libxml2)

@mattt
Copy link
Contributor

mattt commented May 4, 2021

@kean Thanks for sharing your workaround for this issue.

I'm happy to report that I was able to get this working in Xcode 12.5 by using the latest OSS Toolchain. I just updated the README to document this with f2e3185.

@mattt mattt closed this as completed May 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants