Conditional Compilation seems to be not working in Xamarin Studio

KoushikSarkar.6410KoushikSarkar.6410 ✭✭USMember ✭✭

I created a Forms app.
In the code behind for my page I have

        #if __IOS__
        this.MyLabel.BackgroundColor = Color.Navy;

In my ios project options I can see IOS in the "Compiler" tab. (please see screenshot)

But when I run in IOS it doesn't make the label blue.

But if I remove #if IOS block
it makes the label blue.

Please see screenshots.

Any idea what I missed. (I'm on XS. Haven't tried on Visual Studio)

Best Answer


  • KoushikSarkar.6410KoushikSarkar.6410 ✭✭ USMember ✭✭

    Missed one screenshot where I remove the #if block and the navy color takes effect.

  • KoushikSarkar.6410KoushikSarkar.6410 ✭✭ USMember ✭✭

    @ClintStLaurent You are right. I was not aware that they don't work with PCL. Thanks : )
    With Shared they are working as expected.

Sign In or Register to comment.