How to debug Xamarin.iOS application on an iOS physical device

I apologize in advance for this long question, but I spent 3 days on an unsuccessful attempt to configure the Xamarin.iOS development environment, which allows me to debug a physical device (and not an iPhone simulator), and I am in loss for what to try next.

I believe that my setup is a pretty standard Xamarin configuration:

  • Windows 10 PC with Visual Studio 2015 and Xamarin v4.2.0.703
  • HTC USB phone connected to Android PC for debugging (works great)
  • MacBook with OS X 10.11 with Xamarin Studio v6.1.1 and Xcode v8.0
  • iPhone or iPad with Mac USB for iOS debugging

I started by creating a Xamarin solution in Visual Studio, which I originally developed and debugged on Android.

To get started on debugging iOS, I configured Mac with Xcode and Xamarin Studio, enabled it for remote login, and created a dummy Xcode project with the same package ID as my Xamarin.iOS application. I also tried to create a rather complicated process of creating a signature identifier and provisioning profile for the application and downloading / installing on Mac. This process is so unintuitive (and the visual feedback in Xcode is so poor) that I'm not sure I did it right. However, I can run the dummy Xcode project on the iPhone, so I assume it should be okay?

On a Windows PC, the Xamarin > iOS Options panel in the Visual Studio settings confirms that Visual Studio is connected to the Mac, and the attached iPhone is also listed as the target candidate device, so everything seems to be configured for debugging on the device.

If I try to debug an iPhone simulator application from Visual Studio, it works correctly. However, debugging on the physical iPhone fails with the following useless message:

Xamarin.Messaging.Exceptions.MonotouchException: error MT1006: Could not install the application '/Users/Tim/Library/Caches/Xamarin/mtbs/builds/Test.iOS/c4f40041b6c58fc579a727bccfc18614/bin/iPhoneSimulator/Debug/TestiOS.app' on the device 'Tim's iPhone': AMDeviceSecureInstallApplicationBundle returned: 0xe8008001. 

As a comparison, I also tried debugging directly on Mac using Xamarin Studio. Again, the iPhone simulator is working fine, but it’s not even possible to start a debugging session using a physical device, because the connected iPhone is not listed as the target destination device for Debug | iPhone

If I open the project settings and move on to the iOS Debug view, I see that the platform associated with the Debug configuration is iPhoneSimulator . Changing it to the iPhone and saving the configuration, it appears, but the changes are not actually saved. I think this is the reason why my test device is not listed, but I do not quite understand what I need to do for Xamarin Studio to accept my changes.

So, after all this experiment, I am completely lost. It would be helpful to have a complete, reliable AZ tutorial for this installation process, but otherwise, any suggestions I should try would be greatly appreciated.

UPDATE: if I use the configuration of the Ad-Hoc project (in Visual Studio or Xamarin Studio), it correctly deploys and runs the application on the device, but does not attach the debugger. If I explicitly enable debugging in the Ad-Hoc configuration, Xamarin Studio ignores it, but Visual Studio then attaches the debugger, but does not hit any breakpoints. Does all this sound right? Does it offer any hints that I need to change to work with a real Debug configuration?

+5
source share
1 answer

For those who face a similar problem, the decision that I ultimately made entailed a brute force approach.

I started by creating a new Xamarin.Forms solution (using the standard Visual Studio template) and removing unwanted platform projects (UWP and Windows Phone). In this initial state, I confirmed that he was able to run debugging on both Android and iOS devices, as well as their respective emulators / simulators. Everything worked correctly, confirming the correct setup of my Mac, and also giving me the exact configuration of the iOS project needed for debugging.

At this point, I suggested that the configuration problem should be responsible for my previous problems, so I accurately reproduced every detail of the working configuration in my original solution. However, he refused to debug iOS.

Then I began to suspect that the Nuget-related package caused this problem, so I added all the related packages from the original implementation to a new test solution. I expected this to break iOS debugging, but it is not.

Finally, I carefully dragged the entire contents of my original solution (XAML and code files, looked at the models, resources, etc.) into the test solution and continued to debug correctly.

Thus, in the absence of a viable diagnostic procedure, I effectively solved the problem by restoring my solution from scratch. No code was changed, and as far as I know, the configuration settings were not changed, but the new implementation is now reliably debugged in all target environments.

+1
source

Source: https://habr.com/ru/post/1258597/


All Articles