XCode - Library cannot be inserted libclang_rt.asan_ios_dynamic.dylib

Viewed 1659

After updating to Xcode 11.4 suddenly the following error is being thrown from the debugger when my application begins running on a physical iPhone connected to Xcode.

    dyld: warning: could not load inserted library '@executable_path/Frameworks/libclang_rt.asan_ios_dynamic.dylib' into hardened process because no suitable image found.  Did find:
    /private/var/containers/Bundle/Application/40EE2455-9E2E-4259-A997-F439F67E9CE5/sample-app!.app/Frameworks/libclang_rt.asan_ios_dynamic.dylib: code signature invalid for '/private/var/containers/Bundle/Application/40EE2455-9E2E-4259-A997-F439F67E9CE5/sample-app!.app/Frameworks/libclang_rt.asan_ios_dynamic.dylib'

    /private/var/containers/Bundle/Application/40EE2455-9E2E-4259-A997-F439F67E9CE5/sample-app!.app/Frameworks/libclang_rt.asan_ios_dynamic.dylib: code signature invalid for '/private/var/containers/Bundle/Application/40EE2455-9E2E-4259-A997-F439F67E9CE5/sample-app!.app/Frameworks/libclang_rt.asan_ios_dynamic.dylib'

    /private/var/containers/Bundle/Application/40EE2455-9E2E-4259-A997-F439F67E9CE5/sample-app!.app/Frameworks/libclang_rt.asan_ios_dynamic.dylib: stat() failed with errno=1
dyld: Library not loaded: @rpath/libclang_rt.asan_ios_dynamic.dylib
  Referenced from: /private/var/containers/Bundle/Application/40EE2455-9E2E-4259-A997-F439F67E9CE5/sample-app!.app/HeadPop!
  Reason: no suitable image found.  Did find:
    /private/var/containers/Bundle/Application/40EE2455-9E2E-4259-A997-F439F67E9CE5/sample-app!.app/Frameworks/libclang_rt.asan_ios_dynamic.dylib: code signature invalid for '/private/var/containers/Bundle/Application/40EE2455-9E2E-4259-A997-F439F67E9CE5/sample-app!.app/Frameworks/libclang_rt.asan_ios_dynamic.dylib'

Can anyone please explain to me what this library libclang_rt.asan_ios_dynamic.dylib is ?

And how to recover from this issue?

2 Answers

In my case the exception (in Xcode 11.4) was:

dyld: could not load inserted library '.../Build/Products/Debug-iphonesimulator/MyApp.app/PlugIns/UnitTests.xctest/Frameworks/libclang_rt.asan_iossim_dynamic.dylib' because image not found

And the clue in a comment above is right: the issue was caused by thread_sanitizer: true in fastlane configuration for 13.4.1 device. Same flag for 12.4 device did not cause any problem.

I didn't find a better solution than removing this flag.

I also had this issue with the "Undefined Behavior Sanitizer" checked. Seems like this may occur with any sanitizer. Unchecking resolved the issue.

Find the Sanitizer checkboxes in Product > Scheme > Edit Scheme > Run > Diagnostics

Related