'PrepareAppBundle Task Failed Unexpectedly - Xamarin Forms

Things were working fine before but all of a sudden I can't build and deploy my Xamarin Forms 5 app to my iPhone connected to my Windows 11 machine via USB cable.

Initial error I got was the following:

The 'HotRestart.Tasks.DetectSigningIdentity' task failed unexpectedly.

Here's a screenshot of the error:

enter image description here

I then tried to rebuild the project and I got the following error:

The "PrepareAppBundle" task failed unexpectedly.

Here's a screenshot of that:

enter image description here

To make sure it's not my project that's causing the error, I created a fresh new Xamarin Forms app and tried to look at it on my iPhone without changing a single line anywhere in the new app and I ended up with the same exact errors above.

I'm on the latest version of Visual Studio 2022 - version 17.1.3 and my laptop runs Windows 11 with all the latest updates.

I'm able to run the app on Android Simulator AND a physical Android device connected to my laptop via the same USB port. It just seems to be failing on iPhone.

Any idea what's causing this issue?



Solution 1:[1]

Just upgraded Visual Studio to 17.1.4 and the problem is FIXED!!!

Solution 2:[2]

Also happened to me. Did not find a better way than reinstalling Visual Studio Community with the newest version 17.1.3. Seems the error is gone since then. Visual Studio seems to be very unfriendly for Android and iOS development..

Regards

Solution 3:[3]

I had the same error after updating Visual Studio to version 17.1.3

You have 2 options to solve this:

1- If you have mac, pair to it and just rebuild the project the error will gone.

2- unload [YourProject].IOS, this will help till you get a Mac device.

(to unload project, Go to Solution explorer >> right click on [YourProject].IOS >> unload project)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sam
Solution 2 Alltair4747
Solution 3 Abdulla Alaa