James Montemagno
James Montemagno

Live, Love, Bike, and Code.



Device.OS is Obsolete in Xamarin.Forms... What to do?!?!

James MontemagnoJames Montemagno

Of you just updated to Xamarin.Forms 2.3.4 you may have noticed and be freaking out that you have tons of green squiggles that Device.OS and TargetPlatform are obsolete. This was all done in regards to the new changes for OnPlatform.

We can see here that it says to use RuntimePlatform isntead, which is a string… but how do you use it??!?! If you hover over TargetPlatform, and enum, it doesn’t tell you what to replace it with. Don’t be scared as it is an easy fix as Device now includes constant values for each platform. Just replace your TargetPlatform with Device and basically done:

Device now contains:

  • Device.iOS
  • Device.Android
  • Device.WinPhone
  • Device.Windows

How about TargetIdiom?!?!? Well that is still there and not obsolete lols. I assume eventually there will be a RuntimeIdiom, who knows.

Live, Love, Bike, and Code