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!
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.