iphone - 以编程方式检测应用程序是否正在设备或模拟器上运行

标签 iphone ios simulator detect

我想知道我的应用在运行时是在设备上运行还是在模拟器上运行。有没有办法检测到这一点?

原因是用模拟器测试蓝牙 api: http://volcore.limbicsoft.com/2009/09/iphone-os-31-gamekit-pt-1-woooohooo.html

最佳答案

#if TARGET_OS_SIMULATOR

//Simulator

#else

// Device

#endif

请同时引用之前的 SO 问题 What #defines are set up by Xcode when compiling for iPhone

关于iphone - 以编程方式检测应用程序是否正在设备或模拟器上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5775420/

相关文章:

ios - 在蓝色导航栏中的 MFMessageComposeViewController 上取消不可见

ios - 我在哪里使用扩展?

testing - React Native 应用程序可以在浏览器中测试吗?

linux - 调度器模拟器 linsched

ios - 在 URL Scheme OpenURL 之后从 AppDelegate 调用 ViewController 方法

iPhone HUD风格进度条

ios - cocoa pod 依赖管理

javascript - react-native 中的 loadingIndicatorSource 和 defaultSource 属性有什么区别?

ios - Swift 膨胀 [UInt8] 无法使用 miniz lib 缩小

ssl - 相扑 : pass only TLS phases