Forum Xamarin.Forms

__IOS__ and __Android__ not working?


In my PCL i try to use Android and IOS but they won't work... When i define them in the PCL project settings( both debug and release) they will trigger, but they will both trigger! I also added IOS to the iOS specific project on either debug and release, but without succes.. (Android too)
The symbols are only recognized when i add them to the PCL.. but then the problem arise that they are both set and will run iOS and Android code.


  • Same problem here.

  • CraigDunnCraigDunn USXamarin Team Xamurai

    You cannot use compiler directives like this in a PCL.

    The PCL is compiled once and the resulting Portable Library is included in the other projects (eg. the iOS or Android apps). There is no chance for it to be compiled separately for iOS and Android, hence these directives cannot work.

    #if DEBUG and if RELEASE work because they relate to the compilation process itself; but PCLs are not every compiled "for" a given platform, so __IOS__ and __ANDROID__ do not work.

    We have a sharing code options doc that attempts to explain these differences.

    The __IOS__ and __ANDROID__ compiler directives only work in Shared Projects or when you use file-linking.

  • Comparing my project with the TaskyPro example, I noticed my 'shared' project was nog actually a shared project. The root of the project had a .csproj file, instead of a .shproj.

    I couldn't find out how to actually create the correct shared project (the create shared project still generated a .csproj file), so I simply copy-pasted the TaskyPro shared project in my solution and manually added it through Add > Add Existing Project.

Sign In or Register to comment.