简体   繁体   English

如何检查 iOS 应用程序是否在模拟器上运行。 (目标-c)

[英]How to check if an iOS app is running on the simulator. (objective-c)

Is there a way to check if the app is running on the simulator in Runtime?有没有办法在运行时检查应用程序是否在模拟器上运行? I already know how to check at compile time.我已经知道如何在编译时检查。 I want to make sure that the app is running in the simulator at runtime.我想确保应用程序在运行时在模拟器中运行。 (not swift, in Objective-C...) Thank you. (不是 swift,在 Objective-C...)谢谢。

There is no difference between checking in compile/runtime because ios devices and simulators have different architectures - arm64 and x86_64 accordingly and you can NOT run ARM code on the simulator and vice versa.检查编译/运行时没有区别,因为 ios 设备和模拟器具有不同的架构 - arm64x86_64相应地,您不能在模拟器上运行 ARM 代码,反之亦然。 In other words you have two compiled copies of your code which are build for the target platforms.换句话说,您有两个为目标平台构建的代码的编译副本。

To check which one is running you can use the next iOS Simulator SDK flag:要检查哪个正在运行,您可以使用下一个 iOS 模拟器 SDK 标志:

const BOOL IS_SIMULATOR(void) {
#if TARGET_IPHONE_SIMULATOR
    return YES;
#else
    return NO;
#endif
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 标签栏图标均加载,但第一个除外。 在模拟器中工作。 目标c - Tabbar icons all loading except first one. Works in simulator. Objective-c 在 Xcode 中,如何为应用程序构建 Objective-C 库以在 iOS SIMULATOR 上运行? - In Xcode, how to build an Objective-C lib for an app to run on iOS SIMULATOR? Objective-C - 如何在 iOS 模拟器上强制低内存 - Objective-C - How to force low memory on iOS simulator 应用程式适用于ios 4.3模拟器,但不适用于ios 5模拟器。 有任何想法吗? - App works for ios 4.3 simulator, but not ios 5 simulator. Any ideas? 我如何知道目标C代码是否在iOS模拟器中运行? - How do I know if objective C code is running in iOS simulator? 无法在 ios 模拟器上运行我的 flutter 应用程序,该模拟器在 android 模拟器上完美运行。 运行 pod install 时出错 - Unable to run my flutter app on ios simulator which is working perfectly on android simulator. Error running pod install iOS / Objective-C - 如何检查枚举是否可用? - iOS/Objective-C - How to check if an enum is available? 如何在Objective-C中运行应用程序时获取本地通知 - How to get local notification when app is running in Objective-C 如何使用Objective-C在IOS应用中上传.xml文件? - How to upload .xml file in IOS app using Objective-C? 如何在 iOS (Objective-C) 中分享 Facebook Messenger 应用程序的链接? - How to share link to Facebook Messenger app in iOS (Objective-C)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM