之前一直用的這種,不知道為什么不怎么靠譜
#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
}()
}
親測,這種可以
