之前一直用的这种,不知道为什么不怎么靠谱

        #if TARGET_IPHONE_SIMULATOR//模拟器
            
        #else//真机
           
        #endif

  

现在用这种:

  if Platform.isSimulator {
            // Do one thing
            print("isSimulator")
        }
        else {
            jPushId = JPUSHService.registrationID()
        }



struct Platform {
    static let isSimulator: Bool = {
        var isSim = false
        #if arch(i386) || arch(x86_64)
            isSim = true
        #endif
        return isSim
    }()
}

  

 

亲测,这种可以

相关文章:

  • 2022-02-17
  • 2022-12-23
  • 2021-05-23
  • 2022-12-23
  • 2021-12-18
  • 2021-12-28
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-05-20
  • 2021-12-04
  • 2022-12-23
相关资源
相似解决方案