dyld: Library not loaded: @rpath/libswiftCore.dylib: how to fix the error

Online Python Trainer for Beginners

Learn Python easily without overwhelming theory. Solve practical tasks with automatic checking, get hints in Russian, and write code directly in your browser — no installation required.

Start Course

"Poof — and the app crashed": getting to know dyld: Library not loaded: @rpath/libswiftCore.dylib

\n\n

Have you ever launched your Swift app, seen a beautiful splash screen, and then — bang! — a black screen and a console full of red text? Sound familiar? If you've ever encountered the message dyld: Library not loaded: @rpath/libswiftCore.dylib, you know that feeling of mild panic. This question has gathered thousands of views on Stack Overflow, and for good reason: the error is tricky but solvable.

\n\n

In this article, we won't just give you a dry instruction. We'll break down why Swift libraries "get lost" at runtime, how to avoid it, and what to do if you're already in trouble. Let's go!

\n\n

What is dyld and why is it angry?

\n\n

dyld (dynamic link editor) is the dynamic library loader on macOS and iOS. When your app launches, dyld looks for all required libraries at the paths specified in the binary. One such path is @rpath (runtime search path). If a library (e.g., libswiftCore.dylib) is not found at this path, dyld crashes with an error.

\n\n

Simply put: you told the app "take the book from the @rpath shelf," but the shelf was empty. That's the whole mystery.

\n\n

Why does this happen specifically with libswiftCore.dylib?

\n\n

libswiftCore.dylib is the core of the Swift runtime. No Swift code works without it. The error most often occurs in three cases:

\n\n
    \n
  • You are using Xcode 14+ and the project is configured for an older version of Swift.
  • \n
  • You are linking frameworks or CocoaPods that require a specific version of the Swift runtime.
  • \n
  • You forgot to enable "Always Embed Swift Standard Libraries" in the build settings.
  • \n
\n\n

5 ways to fix dyld: Library not loaded: @rpath/libswiftCore.dylib

\n\n

Let's move to practice. Below are proven methods, from simple to complex. For each, I'll provide code or settings examples.

\n\n

1. Enable "Always Embed Swift Standard Libraries"

\n\n

The most common culprit. If your app doesn't embed Swift libraries in the bundle, dyld won't find them on the device.

\n\n

How to fix:

\n
    \n
  1. Open your project in Xcode.
  2. \n
  3. Select Target → Build Settings.
  4. \n
  5. Find Always Embed Swift Standard Libraries.
  6. \n
  7. Set the value to Yes.
  8. \n
\n\n

If you use CocoaPods, check that your Podfile doesn't have a line disabling this behavior:

\n\n
# Bad (may cause the error)\npost_install do |installer|\n  installer.pods_project.targets.each do |target|\n    target.build_configurations.each do |config|\n      config.build_settings['ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'] = 'NO'\n    end\n  end\nend\n\n# Good\npost_install do |installer|\n  installer.pods_project.targets.each do |target|\n    target.build_configurations.each do |config|\n      config.build_settings['ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'] = 'YES'\n    end\n  end\nend\n
\n\n

2. Check Swift version compatibility

\n\n

If you've linked a framework built with Swift 5.7, but your project uses Swift 5.5 — hello, error. The Swift runtime is not 100% backwards compatible.

\n\n

Solution: ensure all dependencies use the same Swift version. Open Terminal and run:

\n\n
# Find out the Swift version for a specific .framework\nstrings MyFramework.framework/MyFramework | grep "Swift"\n# Or check via xcrun\nxcrun swift --version\n
\n\n

If the framework was built with a different version, rebuild it or update it.

\n\n

3. Clean Derived Data and rebuild the project

\n\n

Sometimes Xcode caches old library paths. A full rebuild often solves the problem.

\n\n
# Delete Derived Data manually\nrm -rf ~/Library/Developer/Xcode/DerivedData                

Blogs

Book Recommendations