swift 检查应用程序是否在模拟器或物理iOS设备上运行

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了swift 检查应用程序是否在模拟器或物理iOS设备上运行相关的知识,希望对你有一定的参考价值。

struct Device {
    
    /// Detects if the current architecture is a Simulator
    static let isSimulator: Bool = {
        var isSim = false
        #if arch(i386) || arch(x86_64)
            isSim = true
        #endif
        return isSim
    }()
}

/* 
Usage:

if Device.isSimulator {
  print("Running on a simulator")
}
*/

以上是关于swift 检查应用程序是否在模拟器或物理iOS设备上运行的主要内容,如果未能解决你的问题,请参考以下文章