Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Any way to determine at runtime whether you're running on device or simulator?

The title pretty much asks it all :) Thanks.

— asked June 16th 2010 by Christopher Rumpf
  • detection
  • device
  • emulator
  • runtime
  • simulator
0 Comments

3 Answers

  • Nevermind… I figured it out. For anyone else that is interested it's in the Titanium.Platform obj

    Titanium.Platform.model is 'Simulator'

    and

    Titanium.Platform.username is 'iPhone Simulator'

    — answered June 16th 2010 by Christopher Rumpf
    permalink
    0 Comments
  • 1.7.2 has changed things so that Titanium.Platform.model is now set to 'iPhone Simulator' when running in the simulator. Why the change? - that broke all my code!!

    — answered September 13th 2011 by David Geller
    permalink
    1 Comment
    • I agree. There should be a variable or function one can call for this so they can change what's under the hood anytime. I created my own function call for this check, so I only have to change one location. Now I look at Ti.Platform.username == "iPhone Simulator". If there is a more standard way to do this, I'd love to know.

      — commented October 27th 2011 by Steven Day
  • A colleague I work with has to look for this value from Ti.Platform.model when checking to see if the app is running in the simulator… 'x86_64'.

    For me the iPhone simulator shows as 'Simulator'.

    — answered January 25th 2012 by Julian Fraser
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.