Xamarin.Forms IOS Breakpoints Not Hit

2019-02-16 10:15发布

问题:

I recently upgraded to the new Xamarin for Visual Studio, and since then, I can no longer hit breakpoints during IOS debugging. Android works fine, strangely.

I uninstalled and reinstalled Visual Studio Community Edition 2017 and left all of the defaults intact. Previously, this has resolved odd issues like this one.

I have read dozens of similar complaints, but those solutions have not worked for me.

回答1:

An alternative solution is to disable linking in the iOS project (not PCL project). This worked for me.

  1. Go to iOS project settings
  2. iOS Build
  3. Linker Behavior: Don't Link.


回答2:

Go to your Visual Studio for Mac, Solution explorer and choose the project, Project->Option->Compiler->Debug information, choose “Full” in dropdown.

You need set this "Full" for EACH of those projects in the solution you want to debug otherwise the breakpoint will not kick in.



回答3:

I had the same issue with Visual Studio 2017 on Windows and latest Xamarin using the iOS simulator on remote Mac. Debugging started, but breakpoints were not hit.

Got it working by changing nothing on the Mac or iOS Build options; instead changed the generated Debugging information type in Visual Studio 2017 in Windows from "Full" or "Pdb-only" to "Portable".

I did this for the iOS Platform project as well as the shared Xamarin.Forms project (.NET Standard 2.0).

After this the breakpoints started getting hit in both the Shared project and the iOS platform project. Good times.



回答4:

There is a bug in Xamarin.iOS, which will is fixed in Xamarin.iOS 10.12.0.12 (494fcbc), which should be available in beta channel. The problem seems only to occur in a PCL, which is the case if you set a breakpoint in your portable project (Xamarin.Forms code).

There is a temporary workaround, which worked for me:

Possible temporary workaround: switch the portable class library project(s) to output "portable" PDB files rather than "full" PDB files

  1. Open the portable class library .csproj file in a text editor. For example, right-click the project in the Solution Explorer and select Unload Project, and then right-click it again and select "Edit ...".

  2. Under the PropertyGroup for the "Debug|AnyCPU" configuration, change the DebugType to: portable

  3. Save the change and reload the project.

  4. Build, deploy, and start debugging the iOS app project again.

There is an issue on Android if you do the above steps. To be able to hit the breakpoints on Android again, you have to do this:

Long story short, if you manually delete the "bin" and "obj" folders for each of the projects that you have switched to portable, uninstall the app from the test device, and then clean and rebuild the solution, that should hopefully allow the portable mode to work with Android too. Once you have performed those clean-up steps once, you should in theory not need to perform them again unless you switch the DebugType again.

Edit

On Android I still have troubles, so it's not the perfect way.