Skip to content
This repository has been archived by the owner on Oct 17, 2021. It is now read-only.

Example doesn't run from Xcode #2

Closed
chriseidhof opened this issue Feb 3, 2020 · 6 comments
Closed

Example doesn't run from Xcode #2

chriseidhof opened this issue Feb 3, 2020 · 6 comments
Labels
bug Something isn't working

Comments

@chriseidhof
Copy link
Contributor

chriseidhof commented Feb 3, 2020

If you create a new swift package, open it in Xcode, and add the dependencies and sample code, it fails to run successfully:

dyld: Library not loaded: @rpath/lib_InternalSwiftSyntaxParser.dylib
  Referenced from: /Users/chris/Library/Developer/Xcode/DerivedData/swiftmodulevis-dsdxeurkiqwybuaykcssnhgivnum/Build/Products/Debug/swiftmodulevis
  Reason: image not found

I forgot what causes this bug. Running/building from the terminal works fine. Maybe good to either add a notice or fix this? (I don't have time but wanted to let you know anyway).

This is Xcode 11.3 on Mojave.

@mattt
Copy link
Contributor

mattt commented Feb 3, 2020

Thanks for writing in about this, @chriseidhof. I was hitting the same issue when trying to run unit tests. I think upgrading SwiftSyntax to a newer release should fix the issue, but I'd held off on that until I shipped this initial release. This is a great reminder to take another look.

@mattt
Copy link
Contributor

mattt commented Feb 4, 2020

@chriseidhof I tried fixing this by targeting a different release of SwiftSyntax, but wasn't able to get any of the other tags to work. 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.

@mattt
Copy link
Contributor

mattt commented Feb 14, 2020

@chriseidhof I'm happy to report that this is fixed in the latest Swift 5.2 development builds. I'll wait to close this until the most recent Xcode GM can build and run tests on SwiftSemantics master without a problem.

@mattt
Copy link
Contributor

mattt commented Apr 7, 2020

Update: It looks like this still isn't working in Xcode 11.4.

@liamnichols
Copy link

Its not a proper fix, but I did manage to have some luck in Xcode 12.2 by doing the following:

  1. Edit the scheme, add the DYLD_PRINT_RPATHS environment var and set it's value to 1
  2. Look at the console output to see the directory where the dylib is trying to be loaded from
  3. Find the dylib in Xcode (i.e find /Applications/Xcode-12.2.app -name lib_InternalSwiftSyntaxParser.dylib)
  4. Add a symbolic between where the actual dlyb is in Xcode and where the library is trying to be loaded from

Not ideal, but was enough to get things working at least so I could poke around rather than generating the xcodeproj

@mattt
Copy link
Contributor

mattt commented May 4, 2021

I'm very happy to report that this is working in Xcode 12.5 with the latest OSS Toolchain. I updated the README with fb4aa13.

@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
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants