Search code examples
iosvisual-studio-2022mauimaui-ios

Visual Studio 2022 ignores selected framework context for .NET MAUI


I'm trying to add platform-specific code for iOS to my .NET MAUI app.

I'm targeting an iPhone with net6.0-ios:

enter image description here

However, Visual Studio thinks I'm targeting Android:

enter image description here

Compiling and running the app works fine (breakpoints within iOS preprocessor directive are hit), but it's a hassle to have to implement the iOS-specific code outside of the conditional preprocessor directives (with a bunch of warnings saying types aren't available) to be able to get some IntelliSense.

I'm suspecting this is a bug, but curious if there's any workaround?

Edit: Not a bug, I was just being an idiot not realizing the code editor and debugging target don't necessarily have to be one and the same.


Solution

  • Look in the first picture you posted, at upper left corner. ...App (net6.0-android). That is current value of a dropdown, that determines which project Intellisense uses. Change that to iOS.