Created
July 24, 2021 00:29
-
-
Save corbindavenport/3da222dd6261b54d7ae3bd954a843eca to your computer and use it in GitHub Desktop.
Check for MacOS Rosetta compatibility layer in Dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Function to verify Rosetta compatibility layer is enabled on ARM macOS | |
void checkRosetta() async { | |
var cpu = await getCPUArchitecture(); | |
var rosettaInstalled = await io.Directory( | |
'/Library/Apple/System/Library/LaunchDaemons/com.apple.oahd.plist') | |
.exists(); | |
if (io.Platform.isMacOS && (cpu == 'arm64')) { | |
if (rosettaInstalled) { | |
print('[ OK ] Rosetta compatibility layer is already installed.'); | |
} else { | |
io.stdout.write( | |
'[WARN] Apple Rosetta compatibility layer must be installed. Continue? [Y/N] '); | |
var input = io.stdin.readLineSync(); | |
if (input?.toLowerCase() != 'y') { | |
print('[ .. ] Please wait while Rosetta is installed...'); | |
await io.Process.run('/usr/sbin/softwareupdate', | |
['---install-rosetta', '--agree-to-license']); | |
} else { | |
io.exit(1); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment