question

Marc-4934 avatar image
0 Votes"
Marc-4934 asked MuhammadAnasAnsari-8209 answered

iOS App crashes immediately after debug start

After updating VS2019 a while back I could not debug my app anymore. After a lot of research at that time, there was a statement, that this problem should be fixed in the next VS update. Now some VS updates later I wanted to check out if the problem was fixed, but unfortunately it is not for me.

What is happening:
I can run my build succesfully and get the build message, that the application is started succesfully as well. The debugger starts, the application opens up but closes immediately after.
The console of VS and the debugger do not show any output. While the App is already closed on the device, the debugger of VS is hanging for a while until VS is back to developing mode. The only line in the debug output now is "the app was closed".

What I already tried:
-updating/consolidating all packages
-changing and renewing apple certificates
-try hitting breakpoints, but it is not even hitting the first line of iOS Main.cs
-switching of Hot Reload
-reinstall Xcode on the mac buildhost (current version: 12.5.1)
-updating/reinstall VS (current version: 16.10.03)
-creating new empty project (works fine)

strange behavior:
but the strange thing now is, I copied over the project directly to the build host and opened it there with VS for mac. Running the build directly from the mac worked like a charm. The application starts and runs without any issues.

My problem:
My main problem here is, that I do not get any usefull output on what may causes this issue. Maybe someone knows, which log I have to look for to get some helpful information or even had the same problem.
The only hint so far for me is a line from the build log:

/private/var/containers/Bundle/Application/xxxxxxxxx/xxxxxxxxx.iOS.app/libxxxxxxxxx.iOS.exe.dylib: code signature in (/private/var/containers/Bundle/Application/xxxxxxxxx/xxxxxxxxx.iOS.app/libxxxxxxxxx.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.

This obviously looks like there is some problem with the signing certificates, but I am using the same signing settings as the working ones while building directly on the mac.

Thanks for your help in advance.

dotnet-xamarin
· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi, Marc. Do you check the Remote Simulator to Windows option? There is a problem when deploying an Xamarin.iOS project via Visual Studio 2019 in this case. The workaround is to disable the remote simulator (Tools -> Options -> Xamarin -> iOS Settings, uncheck Remote Simulator to Windows). When the option is disabled, the simulator will run on the Mac instead of on Windows and you can interact with the simulator on your Mac while using the debugger, etc. on Windows.

Check the link: https://developercommunity.visualstudio.com/t/VS-2019-1694-cannot-connect-to-iOS-Sim/1412563#T-N1422248

0 Votes 0 ·

Hello Jarvan,

first of all, thanks for your reply.
Currently I am deploying to a real device connected via USB to the mac. I am not using the windows building, so there is no simulator involved. The Build should always be done by the mac.

I found out, that maybe this additional info is helpful to pinpoint the problem.

dyld: Library not loaded: @rpath/libDachDeckerApp.iOS.exe.dylib
Referenced from: /private/var/containers/Bundle/Application/xxxxxxxxxxx/xxxxxxx.app/xxxxxxx.iOS
/private/var/containers/Bundle/Application/xxxxxxxxxxxx/xxxxxxxx.iOS.app/libxxxxxxx.iOS.exe.dylib: stat() failed with errno=1
Reason: no suitable image found. Did find:
/private/var/containers/Bundle/Application/xxxxxxxxx/xxxxxxxx.iOS.app/libxxxxxxxx.iOS.exe.dylib: code signature in (/private/var/containers/Bundle/Application/xxxxxxxxxxxxxxxxxxxxxx.iOS.app/libxxxxxxxxxx.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.

I also found this article about the same problem but it did not solve it for me:
https://github.com/xamarin/Xamarin.Forms/issues/14124

0 Votes 0 ·

What I already tried: -creating new empty project (works fine)

Hi, Marc-4934. Have you tried to empty the bin and obj folders of the project to clear the cache? Then reopen the VS to bulid the project.

mapped file has no cdhash

It seems that the code isn’t signed. Do you use a third party service that requires sign? Try to resign for the service.
Check this link: https://docs.microsoft.com/en-us/answers/questions/427440/xamarin-ios-app-crashes-on-startup-after-updating.html

Similar issue you could refer to: https://developer.apple.com/forums/thread/682840
0 Votes 0 ·

I tried to delete the obj and bin folders manually and rebuild the project. Sadly, it did not fix the problem.
I found another post, that looks exactly like my problem, but they could not fix it either other then downgrading VS19 to previous working versions.

https://developercommunity.visualstudio.com/t/vs-1610-xcode-125-cannot-deploy-debug-to-physical/1435808

I am also not aware of any 3rd party service, that requires signing. As I described, everything works fine building it on the mac with VS for mac. That maybe pinpoints it to some problem related with the linking and or signing of the dll on VS on windows?


Do you have any idea, which logs I could give you to provide you some more detailed information?

0 Votes 0 ·
Show more comments
daneller-0802 avatar image
0 Votes"
daneller-0802 answered

I'm not sure if we are talking about the same issue. I'm new at this and trying to figure things out as I go so forgive me if we are talking about totally different issues.

I received the error " build error could not find '/var/containers/bundle/application/..."
This happened out of the blue. I had been working on the project 2 hours prior.

In desperation I went to build--> rebuild solution and tried to run it to no avail. Then went to build--> build solution and BAM it worked. Beats me but what a relief

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

MuhammadAnasAnsari-8209 avatar image
0 Votes"
MuhammadAnasAnsari-8209 answered

HI. The same issue is faced by some others peoples too. For this we have to wait for the updating of the VS so may be this error have to removed. you may check for the VS version 17.2.6 in this your problem would be resolved.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.