Craig Otis
Craig Otis

Reputation: 32054

Unable to load Swift runtime library (image not found)

I updated one of my core frameworks to use Swift as an experiment. It builds fine, the compatibility header has the Swift classes available to the Objective-C classes that depend on them, and everything compiles fine.

However, when launching the application (base SDK and deployment target OS X 10.10) it crashes immediately with:

dyld: Library not loaded: @rpath/libswift_stdlib_core.dylib
  Referenced from: /Users/Craig/Library/Developer/Xcode/DerivedData/MacApp-dxcgahgplwpbjedqnembegifbowj/Build/Products/Debug/Fluffy.framework/Versions/A/Fluffy
  Reason: image not found

Note that MacApp is the application I'm launching, and it uses the Fluffy framework containing Swift code.

The Fluffy project has its Runpath Search Paths set to:

@executable_path/Frameworks

But I have also tried it blank. I have tried restarting Xcode, to no avail. Using Yosemite 14A298i and Xcode beta 4.

Upvotes: 2

Views: 3656

Answers (2)

Mudith Chathuranga Silva
Mudith Chathuranga Silva

Reputation: 7434

If you faced Library not loaded error in run time you should add those libraries in Embedded Binary.

Step 01 :-

Make sure that library is in the current project Navigation. If not Drag and drop library in to your project navigation.

Step 02 :-

Click on project > General > Embedded Binary > Add library which showed in your error. In this case you should add libswift_stdlib_core.

enter image description here

Upvotes: 0

Craig Otis
Craig Otis

Reputation: 32054

The Runpath Search Paths for my framework (Fluffy) containing the Swift code needed to be updated. It originally contained:

$(inherited)
@executable_path/../Frameworks

But after creating a sample Swift project and comparing the build settings, Xcode was adding:

@loader_path/Frameworks

To the newly-created project. This was missing from my existing framework project. Adding it so the Runpath Search Paths contained these values solved the problem:

$(inherited)
@executable_path/../Frameworks
@loader_path/Frameworks

Upvotes: 6

Related Questions