Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MonoTouch runtime test to see if it's running in the simulator

Probably really simple, but I can't find an answer - how can I do a check at runtime (using MonoTouch) to make sure I'm in the iPhone simulator (or not) ?

Thanks

like image 519
SomaMan Avatar asked May 30 '12 10:05

SomaMan


People also ask

How do I use the Mono runtime?

The Mono runtime can be used as a stand-alone process, or it can be embedded into applications Embedding the Mono runtime allows applications to be extended in C# while reusing all of the existing C and C++ code. For more details, see the Embedding Mono page and the Scripting With Mono page.

What are the limitations of MonoTouch?

MonoTouch:Limitations 1 Limited Debugging Support. There is no support for debugging in MonoTouch,... 2 Limited Generics Support. Generic virtual methods aren’t supported,... 3 No Dynamic Code Generation. Since the iPhone’s kernel prevents an application from generating code... 4 No Remoting. The Remoting stack is not available on MonoTouch.

Does mono work on 64 bit systems?

For Mono to gain wide adoption in the UNIX world, it is necessary that the JIT engine works in most of today’s commercial hardware platforms. The new Mono engine now supports both 32 and 64 bit systems and various architectures (See Supported Platforms ). Mono provides a number of profiling tools and code coverage tools.

Why pre-compile Mono code to native?

The idea is to allow developers to pre-compile their code to native code to reduce startup time, and the working set that is used at runtime in the just-in-time compiler. Although in Mono this has not been a visible problem, we wanted to pro-actively address this problem.


1 Answers

You can do it like this:

using MonoTouch.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 58
Rolf Bjarne Kvinge Avatar answered Nov 14 '22 21:11

Rolf Bjarne Kvinge