2017-02-20 119 views
0

我想在模拟器中运行某些参数或在服务器上运行 。是否有可能判断它是否在模拟器或应用程序中的真实设备上运行

例如=>服务器名称

  • 在模拟器=>本地主机
  • 在真实设备=> myserver.com

现在,我的环境是钛。

但是我想知道它可能在Xcode上。

这可能是一个很好的提示,如果不可能的onxcode,这是不可能在钛。

+0

对于的XCode:http://stackoverflow.com/questions/5775420/programmatically-detect-if-app-is-being-run-在设备或模拟器或钛上http://stackoverflow.com/questions/13090844/how-can-i-tell-if-my-titanium-app-is-running-on-the-simulator-or-不是? – Larme

+0

谢谢你这个链接对我有用。 – whitebear

回答

1

对于Android的

Build.FINGERPRINT.startsWith("generic") 

对于iOS

#define SIM(x) if ([[[UIDevice currentDevice].model lowercaseString] rangeOfString:@"simulator"].location != NSNotFound){x;} 

SIM(NSLog(@"This will only be logged if the device is simulated")); 
相关问题