dyld: Library not loaded: @rpath/libswiftCore.dylib

I've been trying to solve this issue for hours, and none of the online solutions seem to help.


Any time I run a swift app in the simulator, all is well. But when I try to depoly to a device, I get:


Console Output:

dyld: Library not loaded: @rpath/libswiftCore.dylib
  Referenced from: /var/mobile/Containers/Bundle/Application/5E3D4DDC-1CEF-455D-9687-FAA3D426D2EC/Test2.app/Test2
  Reason: no suitable image found.  Did find:
  /private/var/mobile/Containers/Bundle/Application/5E3D4DDC-1CEF-455D-9687-FAA3D426D2EC/Test2.app/Frameworks/libswiftCore.dylib: mmap() errno=1 validating first page of '/private/var/mobile/Containers/Bundle/Application/5E3D4DDC-1CEF-455D-9687-FAA3D426D2EC/Test2.app/Frameworks/libswiftCore.dylib'


Crash Log Output:

dyld`dyld_fatal_error:
->  0x12002d088 <+0>: brk    #0x3


- This happens with any of Xcode's templates, as long as the language is Swift

- I'm on OS X 10.11, Xcode 7.1, iOS 9.1, and have tried depolying to iPhone, iPad, and Apple TV

- This does not happen when the project is in Objective-C


Things I've tried to resolve this issue:

- Clean & Build

- Restart Xcode

- Restart El Capitan

- Set "Embedded Content Contains Swift" to YES (http://stackoverflow.com/questions/24002836/dyld-library-not-loaded-rpath-libswift-stdlib-core-dylib)

- Set Runpath Search Paths to @executable_path/Frameworks (http://stackoverflow.com/questions/24002836/dyld-library-not-loaded-rpath-libswift-stdlib-core-dylib)

- Revoking my developer certificate, and having Xcode regenerate it

- Revoking my developer certificate, and regenerating it myself in developer.apple.com (http://stackoverflow.com/questions/26024100/dyld-library-not-loaded-rpath-libswiftcore-dylib)

- Deleting all derived data, and Xcode caches

- Reinstalling the WWDR Certificate (https://forums.developer.apple.com/thread/15174)

- Deleting all keychain certificates, and reinstalling the ones I needed


On the verge of reinstalling my whole OS to try and fix this. Does anyone know how to solve this issue?


Kind Regards,

Chris

Replies

Yikes. Just to double-check, you did get Xcode from the Mac App Store, right? Concerned that someone may have tampered with your copy of libswiftCore.dylib. Even if that isn't the case, reinstalling Xcode is likely to help more than reinstalling the OS, if you haven't done so already.


Sorry you're seeing this, whatever the cause!

I'm getting this error. It's very random and usually fixes itself when I do a clean project. Unfortunately that doesn't work on my coworker's machine (he cleaned the project / restarted the machine / deleted the app etc). Happens only when you try to run it on the device though.

What a horrible problem. I tried everything as OP. The solution is to reinstall the WWDR:


https://forums.developer.apple.com/message/43547#43547

@XmasRights, Did you resolve this. Can you share what you did to fix. We are going through same frustration and steps like you did. Almost ready to dump swift.

I am experiencing this exact issue too, and have tried almost all the suggested in the OP post to no avail.


I have tried resintalling the WWDR cert and that does not help. I have also tried installing all the intermediate certs from Apple at http://www.apple.com/certificateauthority/


Keychain Access evaluation of my developer cert for code signing passes.


Performing the step

- Set "Embedded Content Contains Swift" to YES (http://stackoverflow.com/questions/24002836/dyld-library-not-loaded-rpath-libswift-stdlib-core-dylib) does change the nature of the crash. After doing that, the crash output is just a non-informative "(lldb)" -- but typing bt after it yields:

(lldb) bt

* thread #1, stop reason = signal SIGABRT

* frame #0: 0x0000000104e66f1c dyld`__abort_with_payload + 8

frame #1: 0x0000000104e666f4 dyld`abort_with_payload_wrapper_internal + 100

frame #2: 0x0000000104e66720 dyld`abort_with_payload + 12

frame #3: 0x0000000104e3c498 dyld`dyld::halt(char const*) + 312

frame #4: 0x0000000104e3f714 dyld`dyld::_main(macho_header const*, unsigned long, int, char const**, char const**, char const**, unsigned long*) + 7376

frame #5: 0x0000000104e3921c dyld`_dyld_start + 68

(lldb)

Insight into this issue would be appreciated. Trying to find a workaround has already cost an entire day of work.

Were you able to solve this? I'm have the same problem and tried all the same steps without success.

I had the same problem:

dyld: Library not loaded: @rpath/libclang_rt.asan_ios_dynamic.dylib

Referenced from: /private/var/containers/Bundle/Application/.../Frameworks/....framework/...

Reason: image not found

This is my own app with my own (build for debug) framework.

What solved it for me is to make sure the Diagnostics ticked in the Run scheme are the same for the app and for the framework.

This was not needed with Xcode 9.2...

Hi @TvNuland,


When you say "Diagnostics ticked in the Run scheme", can you ellaborate?

In my scheme the run section doesn't have this option, it does have a Diagnostics tab though.

I'm using Xcode 10.0


Unless you mean, make sure all the ticks on the diagnostic tab are the same for your framework and app?

Although I tried this and it didn't fix the issue for me.


But I only have Runtime Api checking - main thread checker and pause on issues check on that screen though.


Best reagrds,


Jules.

Jules,


Sorry for the late response, I wasn't in the office for the weekend 🙂

I am still on Xcode 9.4.1


Yes, I did make sure all the ticks on the diagnostic tab are the same for my framework and app, that was what solved it for me...

I also have Runtime API checking - main thread checker and pause on issues both checked.

But also Runtime sanitization - address sanitizer and detect use of stack after return both checked (for the framework and the calling app).