let arch=NSRunningApplication.current.executableArchitecture
switch arch {
case NSBundleExecutableArchitectureARM64 :
print("App is running in ARM CPU mode")
case NSBundleExecutableArchitectureX86_64:
print("App is running in INTEL CPU mode")
default :
print("UNKNOWN CPU MODE")
// there are other values, but they are all 32bit oriented
}
public enum CPU_TYPE : String {
case arm64
case intel64
case unknown
}
public var appCPU : CPU_TYPE {
let arch=NSRunningApplication.current.executableArchitecture
switch arch {
case NSBundleExecutableArchitectureARM64 : return .arm64
case NSBundleExecutableArchitectureX86_64 : return .intel64
default : return .unknown
}
}
public var usingRosetta : Bool {
var ret = Int32(0)
var size = 4//ret.byteWidth
let result = sysctlbyname("sysctl.proc_translated", &ret, &size, nil, 0)
if result == -1 {
if (errno == ENOENT) { ret = 0 } else { ret = -1 }
}
return (ret != 0)
}
Like Geoff’s assumption that macOS 10.16 is the same as macOS 11.0, while these are often interchanged, when the OS reports it to your app, there is a technical reason for this, which has an impact on your apps capabilities.