Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MonoTouch compiler directive for iPhone Simulator

Does anyone know the compiler directive I'd use in MonoTouch to see if I'm running in the iPhone simulator? Can't find any info anywhere.

Thanks!

like image 940
SomaMan Avatar asked Jun 07 '12 08:06

SomaMan


1 Answers

There is no compiler directive (conditional compilation symbol) to determine if you're running in the iPhone simulator or on a device.

You can however determine it at runtime, using this code:

using ObjCRuntime;
static bool InSimulator ()
{
    return Runtime.Arch == Arch.SIMULATOR;
}

This is from here: http://docs.xamarin.com/ios/recipes/General/Projects/Environment_Checks

like image 145
Rolf Bjarne Kvinge Avatar answered Nov 13 '22 09:11

Rolf Bjarne Kvinge