M1 and Rosetta

If I produce a Universal App… how can that app detect if it is running on M1 or Intel

NOT “Is Rosetta available”, but which mode is the Universal app running under

in that same vein, is it possible to force a Univeral to run specifially in one mode or another (for testing)

  1. Apple Developer Documentation

  2. I think so but not by your app once it has launched
    On an M1 you should be able to use the GetInfo window to tell the OS how to start the app

Ah Dave clarified elsewhere and wants to know not the architecture of the machine but the architecture the app is running AS

NSRunningApplication has it

SO between that & sysctl you can tell if you are running under rosetta as well

1 Like

How to tell what mode an app is running as

	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

Here are some better versions

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)

Here is how to get the REAL CPU in the machine

public var realCPU :String {
	let info = NXGetLocalArchInfo()
	return NSString(utf8String: (info?.pointee.description)!)! as String

this may return ARM64E which is same as ARM64

Don’t be fooled, these are not the same.

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.

Well my brand new Mac Studio with an M1-Max returns “ARME”

The purpose of the above routine is primarily to indicate if it is or is not INTEL

ARME in German language means poor people…

indeed not the same in many ways

1 Like

… or ARMS (like in “arms and legs”, not like arms as weapons)