import UIKit
struct Platform {
static let isSimulator: Bool = {
var isSim = false
#if arch(i386) || arch(x86_64)
isSim = true
#endif
return isSim
}()
}
func timeZoneLocalDate() -> NSDate {
if Platform.isSimulator {
print("a")
// Do one thing
let timeZone: NSTimeZone = NSTimeZone.localTimeZone()
let currentGMTOffset: Int = timeZone.secondsFromGMT
return NSDate().dateByAddingTimeInterval(NSTimeInterval(currentGMTOffset))
}
print("b")
return NSDate()
}
참고 : http://stackoverflow.com/questions/24869481/detect-if-app-is-being-built-for-device-or-simulator-in-swift