Home.NETUsing Conditional Compilation in Xamarin Shared Project for iOS

Using Conditional Compilation in Xamarin Shared Project for iOS

There are times when you might want to perform an action that is specific to a device in the Xamarin Shared Project.

For example , assume that you have to set the string named title within the Xaml page present in the Xamarin Shared Project only for iOS devices to a specific text, you can use the conditional compilation directive as shown below.

string Title = "";
#if __IOS__ 
 
   Title = "This is an iOS App"; 
 
#endif 

Where did we get this __IOS__ directive from ?

Right click on the <AppName>.iOS project in the Solution Explorer and navigate to the Project properties Window.

Select Build from within the iOS project properties screen and you would fine the __IOS__ in the Conditional compilation symbols textbox as shown.

image

Leave a Reply

You May Also Like

In this post, you’ll learn about the error message “WorkbookNotSupported – The file you selected cannot be opened because it...
  • .NET
  • December 17, 2022
In this post, you’ll learn about the error message “SpecifiedRangeNotFound – The requested range does not exist in the sheet.”...
  • .NET
  • December 17, 2022
In this post, you’ll learn about the error message “SheetRangeMismatch – The sheet provided as the sheet argument is not...
  • .NET
  • December 17, 2022