VS Xamarin.Forms Shared Project template doesn't provide a __IOS__ compilation symbol

ChrisSellsChrisSells USUniversity ✭✭

By default, if you run the Blank App (Xamarin.Forms Shared), there is a WINDOWS_PHONE compilation symbol and a ANDROID compilation symbol, but there is no IOS compilation symbol. The WINDOWS_PHONE symbol is defined in the WP project, but I don't know where the ANDROID symbol is defined. However, there isn't a IOS symbol defined anywhere, because code inside a #if IOS block isn't executed.

Posts

  • MitchMilamMitchMilam USMember ✭✭✭

    IOS is defined in the IOS project.

    Why do you need the compilation symbols?

  • CraigDunnCraigDunn USXamarin Team Xamurai

    Xamarin projects should define their platform symbols with two leading and trailing underscores, eg.

    #if __IOS__
    #if __ANDROID__
    #if __MOBILE__   // set for both Xamarin.iOS and Xamarin.Android
    

    Our Android compiler also adds __ANDROID_15__ or whatever API level the project is being compiled at for even finer grained control (you can confirm these by closely examining the build output in the IDE, as they are passed to the compiler).

    You could be seeing a bug in the template shipped for Visual Studio if these are not working for you. I just checked Xamarin Studio and it seems fine; can look at Windows tomorrow....

  • ChrisSellsChrisSells USUniversity ✭✭

    In VS2013u3 with the latest Beta version of the Xamarin platform, I'm seeing the _ _ ANDROID _ _ symbol and the WINDOWS_PHONE symbol but not the _ _ IOS _ _ symbol unless I define it on the iOS project myself (I had to put the spaces around the underscores to keep Markdown from claiming them). It looks like a bug to me.

  • MihaMarkicMihaMarkic SI ✭✭✭✭

    Yep, same here - no _ _ IOS _ _ nor _ _ MOBILE _ _ out of the box (actually no conditional compilation symbol is defined at all for iOS project.

  • CraigDunnCraigDunn USXamarin Team Xamurai

    Hey guys, I just created a blank Xamarin.Forms Shared Project using Visual Studio 2013 Update 2 with Xamarin 3.2.5 (according to the Visual Studio About screen)... and the compiler symbols are present (ref screenshot).

    Which versions are you guys using?

    Are they present in the iOS project if you create a Xamarin.Forms PCL solution?

  • ChrisSellsChrisSells USUniversity ✭✭

    Thanks, Craig. Here are my versions:

        Microsoft Visual Studio Professional 2013
        Version 12.0.30723.00 Update 3
        Microsoft .NET Framework
        Version 4.5.51641
    
        Xamarin   3.5.25.0 (fd9f6c6d6de9dd8a23f5bc52d60ec7b31b3dc889)
    

    Neither the PCL nor the Shared Project templates produce a _ _ IOS _ _ symbol in the iOS project nor a _ _ ANDROID _ _ symbol in the Android project.

  • CraigDunnCraigDunn USXamarin Team Xamurai
    edited August 2014

    I think the __ANDROID__ ones are compiler generated (because the __ANDROID_15__ etc ones are dynamic in a way), so you won't see them in the properties (but they should "work" in your code, for example; this is easily testable).

    As for __IOS__, your version of Xamarin is a lot newer than mine apparently (3.5.25 > 3.2.5) so I'm trying to figure out if this is a regression or something... the project properties should look like the screenshot I posted!

    Oohhh... @ChrisSells‌ is that the Xamarin Beta channel you're using?

  • ChrisSellsChrisSells USUniversity ✭✭

    Thanks, Craig. The Android compilation symbol does work, even though I can't see it. The iOS compilation symbol doesn't work. And I agree with you -- it should. : )

  • CraigDunnCraigDunn USXamarin Team Xamurai

    Ok, I can reproduce the problem (no iOS symbols in Shared Project template) in the Beta channel, but works fine for me in Stable.... so... the best advice for now add them is to add them yourself if you're using an alpha or beta version. Or switch back to Stable.

  • ChrisSellsChrisSells USUniversity ✭✭

    Thanks, Craig. Is there a place I should log a bug?

  • CraigDunnCraigDunn USXamarin Team Xamurai

    Bugzilla is our tracking system. I've already tried tracking this down internally but a bug might help (and then you get notified when it's addressed :)

Sign In or Register to comment.