Way to detect running in simulator?
I'm looking for ways either to detect I'm running in the simulator, or have some different build configuration so that I can have my application use a different URL for the web service it contacts. Typical case is, when I'm doing development, I want the app to talk to the web server running on my local machine. But, when I setup the app for Ad Hoc testing on iPhone, and distribute to phones, etc. I want it to use a public web server.
What are some solutions for this kind of thing?
2 Answers
-
Accepted Answer
Try something like this…..
if (Titanium.Platform.model == 'google_sdk' || Titanium.Platform.model == 'Simulator') {
//Whatever is unique to simulator
} -
Watch out : with SDK 1.8, Titanium.Platform.model does not return "Simulator" anymore in iOS, but "x86_64" for instance.
Here is what I've got :
[INFO] model = x86_64
[INFO] name = iPhone OS
[INFO] version = 5.0
[INFO] ostype = 32bit
[INFO] osname = ipad