6

I am using Windows VS 2019 paired to my Mac. My Xamarin.iOS app has started crashing with this error in the Xcode device logs: DYLD Library not loaded mapped file has no cdhash, Code has to be at least ad-hoc signed.

Visual Studio reports that the app deployed successfully on the iPhone and it starts to open then crashes. This only happens when deploying the app in debug mode. I can deploy in release mode to my iPhone and app store connect and the app runs fine. But I need to be able to debug.

Also, after the app crashes on the phone Visual Studio is still running in debug. But when I stop it a dialog box error pops up that says "The debugger was unable to terminate one or more processes: Mono: The debugger is still attaching to the process or the process is not currently executing the type of code selected for debugging."

I contacted Apple developer technical support but they say they can't help because I'm using 3rd party tools (Visual Studio). This is all they would tell me, "The immediate cause of this error is very clear: Some part of your program is not signed and thus iOS refuses to load it... Because the third-party tool is creating the project that you’re asking Xcode to sign. Specifically, this message: DYLD Library not loaded mapped file has no cdhash means that the code simply wasn’t signed. If you were working with a normal Xcode project you’d never get into this situation."

I have uninstalled and reinstalled all of my Apple certificates in Keychain and made sure the trust setting is set to Use System Defaults. I have revoked and removed all my certificates, identities, and profile in Apple Developer and re-created them. sand I have upgraded Xcode to 12.5 and Visual Studio to 16.10.1.

Here is the error from the Xcode device log:

Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Exception Note: EXC_CORPSE_NOTIFY Termination Description: DYLD, Library not loaded: @rpath/libGT.Partners.Phone_Order_Entry.iOS.exe.dylib | Referenced from: /private/var/containers/Bundle/Application/2F1480CA-1262-4922-B33E-91E0DFC6DFDC/GT.Partners.Phone_Order_Entry.iOS.app/GT.Partners.Phone_Order_Entry.iOS | Reason: no suitable image found. Did find: | /private/var/containers/Bundle/Application/2F1480CA-1262-4922-B33E-91E0DFC6DFDC/GT.Partners.Phone_Order_Entry.iOS.app/libGT.Partners.Phone_Order_Entry.iOS.exe.dylib: code signature in (/private/var/containers/Bundle/Application/2F1480CA-1262-4922-B33E-91E0DFC6DFDC/GT.Partners.Phone_Order_Entry.iOS.app/libGT.Partners.Phone_Order_Entry.iOS.exe.dylib) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed. | /private/var/containers/Bundle/Application/2F1480CA-1262-4922-B33E-91E0DFC6DFDC/GT.Partners.Phone_Order_Entry.iOS.app/libGT.Partners.Phone_Order_Entry.iOS.exe.dylib: stat() failed with errno=1

Has anyone encountered and fixed this? Please help!

jwrule
  • 151
  • 6
  • If you were working with a normal Xcode project you’d never get into this situation. -- This is wrong while working with the Xcode we also get such issues. So the error is clearly saying that the code does not recognize the proper images for the library. (Reason: no suitable image found). You can find different options available to resolve this issue here via Xcode we need to change some settings and paths to able to recognise the image. https://stackoverflow.com/questions/32730312/reason-no-suitable-image-found – msusare Jun 30 '21 at 06:05

2 Answers2

9

In working with Microsoft they found a bug in Visual Studio. They found that the issue is entirely around the incremental build option. This seems to be broken in Visual Studio 2019 on Windows when deploying to a iPhone connected to the Mac. They could reproduce the exact error in a template project just by enabling incremental builds.

Apparently incremental builds work by creating that lib.exe.dylib dynamic library to allow building and loading just the changes so the bug seems to be that the generated incremental library is not being signed correctly.

When I disable incremental builds I am able to deploy my app to the iPhone and debug it.

jwrule
  • 151
  • 6
  • 1
    Hi @jwrule! How did you disable incremental builds? – wallef Aug 24 '21 at 13:22
  • 1
    In the iOS Build tab (there is also a Build tab but it's not this one) in the project's properties there is a check box Enable incremental builds. I just cleared the checkbox. – jwrule Aug 25 '21 at 14:55
  • 1
    You are MY MAN dude. That's exactly what Microsoft broke since VS 16.10.x. I was searching since weeks what could have caused this issue. That saved my day! BIG THX! – M. Hartner Sep 17 '21 at 14:23
5

Uncheck "Enable Incremental builds" in iOS Build settings. Thanks to @jwrule.

incremental build

Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
  • Please don't add "thank you" as an answer. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation), you will be able to [vote up questions and answers](https://stackoverflow.com/help/privileges/vote-up) that you found helpful. - [From Review](/review/late-answers/30008049) – sorosh_sabz Oct 06 '21 at 21:17