Clear Rosetta Flag for Desktop App

A little bit of background: If you make an app with no compiled Arm64 binaries in the Content/MacOS folder, MacOS erroneously identifies it as an Intel based app. After launching the app, MacOS will prompt the user to install rosetta, despite the app running fine natively. I found a simple solution to this issue, either include a do-nothing compiled binary to Contents/MacOS, or add

    <key>LSArchitecturePriority</key>
    <array>
        <string>arm64</string>
    </array>

to the plist.

The problem is this change only fixes the issue if you also change the BundleID. If you run the app even once with the bad configuration, MacOS seems to cache the intel flag somewhere based on the BundleID. It does not seem to be cached in the usual places.

How to reproduce: (On apple silicon)

  1. You probably already have rosetta, and it is a pain to remove, so a VM is likely needed.
  2. Make an empty app with Script Editor, export with file format: Application.
  3. Replace Example.app/Content/MacOS/applet with a script of the same name. Make sure the old applet is gone, don't rename it and leave it in the directory. I used:
#!/usr/bin/osascript
display dialog "Hello, world"
  1. Make it executable sudo chmod +x ./Example.app/Content/MacOS/applet
  2. Run the app and observe that it asks you to install rosetta
  3. Add the previously mentioned fix to you plist, including the BundleID change
  4. Run it again and observe that it now works
  5. Change your BundleID back. Running this now raises the rosetta prompt despite the fact that it runs fine on a clean install of MacOS.

Things I have tried:

  • Rebooting, no effect
  • Reforming the app, no effect
  • Reboot in recovery mode, no effect
  • lsregister -delete, no effect
  • ~/Library/Preferences, ~/Library/Caches, /Library/Preferences, and /Library/Caches, none contain an entry for the BundleId
  • defaults delete, domain not found
Answered by DTS Engineer in 798880022

I generally recommend that you not create an app whose main executable is a script. This Rosetta issue is a new one on me, but doing this will create other issues as well [1].

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] Like the TCC issue I discuss in On File System Permissions.

I generally recommend that you not create an app whose main executable is a script. This Rosetta issue is a new one on me, but doing this will create other issues as well [1].

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] Like the TCC issue I discuss in On File System Permissions.

It's quite unfortunate that this still does not have a workaround or solution. This notion that the main executable must be a binary introduces complexities for apps that rely on just-in-time compilation frameworks. The LSArchitecturePriority flag fixes this for new Desktop users, but without a way to "clear" this flag, it will be stuck until a user creates a new profile or reloads their mac.

With regards to Java, OpenJDK has finally offered a jpackage utility starting with JDK17, however projects relying on LTS versions such as JDK11 are faced with a dilemma of whether or not to introduce native compilation into a project or struggle with bugs that are a side-effect of the script being the main executable.

doing this will create other issues as well

Agreed. We're facing another issue where setOpenURIHandler is ignored as well. The docs say this is handled by Info.plist, however it appears to be handled more like an entitlement on the main binary, blocking a Java application from receiving any URI strings at runtime. OpenJDK does not believe this to be a bug. More and more issues will occur as a result of this, however the lack of workaround makes supporting these apps in the interim frustrating to "framework" ISVs supporting the Apple Ecosystem.

Ok, I found a workaround to clear this flag after it's been cached...

/usr/libexec/PlistBuddy -c "Delete :\"Architectures for arm64\":io.qz.qz-tray" ~/Library/Preferences/com.apple.LaunchServices/com.apple.LaunchServices.plist && sudo reboot

... where io.qz.qz-tray is the bundle identifier of your application.

The reboot is critical for the setting to take effect.

Clear Rosetta Flag for Desktop App
 
 
Q