Search code examples
xcodemacosswiftosx-yosemite

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.


Solution

  • 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