Ask Different (Apple)
Q&A for power users of Apple hardware and software
Latest Questions
5
votes
1
answers
316
views
Why is a macOS app whose executable is a shell script launching as x86_64 on an arm64 mac?
I have a macOS application whose executable is a shell script. That is, the file in its `Contents/MacOS` subdirectory whose name is specified in its `CFBundleExecutable` property is an executable shell script rather than a binary. I want the script's process to match the system's architecture by def...
I have a macOS application whose executable is a shell script. That is, the file in its
Contents/MacOS
subdirectory whose name is specified in its CFBundleExecutable
property is an executable shell script rather than a binary.
I want the script's process to match the system's architecture by default, and its running architecture matters because the script has some logic in it that does different things depending on the architecture.
Per Apple's documentation, its Info.plist file contains an LSArchitecturePriority
key that prioritizes arm64 over x86_64 so that it will run natively on Apple Silicon macs.
However if I launch the app from the Finder, for some reason it's always running as x86_64 instead of arm64.
I confirmed this by making the shell script contain the following:
#!/bin/sh
uname -m >> ~/Desktop/log.txt
sleep 5
...and seeing that the text that gets appended to log.txt
is always x86_64 if I launch the app from the Finder. I can also see its architecture is Intel in Activity Monitor.
I know there are other ways of detecting whether the script is running on an arm64 mac, regardless of whether the process itself is arm64 or x86_64, but I want the user to be able to run the app using either architecture (for example by using arch -x86_64
or arch -arm64
when running it from the command line). But it should always default to the system's native architecture when launched from the Finder. This isn't a problem if an app bundle's executable is a universal binary, so it seems to be related to it being a shell script.
Why is it launching as x86_64 instead of arm64? Is there a way to fix it?
I did find one relevant bit of Apple's documentation in [Building a Universal macOS Binary](https://developer.apple.com/documentation/apple-silicon/building-a-universal-macos-binary) :
> If an app doesn’t contain an executable binary, the system may run it under Rosetta translation as a precautionary measure to prevent potential runtime issues. For example, the system runs script-only apps under Rosetta translation. If you verified that your app runs correctly on both Apple silicon and Intel-based Mac computers, add the LSArchitecturePriority key to your app’s Info.plist file and list the arm64 architecture first.
Given that using LSArchitecturePriority
isn't working, this is looking increasingly like a macOS bug, but I'm curious if there's any workaround or other explanation as to what's going on.
Bri Bri
(2930 rep)
Nov 10, 2023, 04:13 PM
• Last activity: Jul 9, 2024, 05:45 PM
4
votes
0
answers
1146
views
Remove x86 code from universal app
I'm using macOS 12 on an M1 MBP. There are certain apps that are mostly code and not resource, very large in size, and not needed in Rosetta. Therefore, I wrote a script to remove x86 components from these applications. The script is very slow and the current way of checking that the applications st...
I'm using macOS 12 on an M1 MBP. There are certain apps that are mostly code and not resource, very large in size, and not needed in Rosetta. Therefore, I wrote a script to remove x86 components from these applications. The script is very slow and the current way of checking that the applications still work is simply to open it, which is not a very comprehensive check. So:
1. Is there any other solutions, tools, or scripts that can perform this faster?
2. Is there a more thorough check I can perform to ensure that the application, after removing the x86 code, still works perfectly, and that I can delete the clone / backup I made before the process?
Script in fish:
cd /path/to/application/bundle/
for i in ** ; lipo -extract arm64 $i -o $i.1 ; mv $i.1 $i ; end
Joy Jin
(3043 rep)
Oct 6, 2022, 12:46 AM
• Last activity: Oct 6, 2022, 11:10 AM
0
votes
0
answers
1167
views
Activity Monitor does not have the "Kind" column
Activity Monitor doesn't show the "Kind" column, and does not give me the option to enable it. It's not in the list of columns I can enable. My friend's M1 Mac has the Kind column in the list of columns he can enable. It's between Real Shared Memory and Sudden Termination. It's not there for mine. T...
Activity Monitor doesn't show the "Kind" column, and does not give me the option to enable it. It's not in the list of columns I can enable.
My friend's M1 Mac has the Kind column in the list of columns he can enable. It's between Real Shared Memory and Sudden Termination. It's not there for mine. The light-colored screenshot is my Mac. The dark-colored screenshot is my friend's. You can see the Kind column is highlighted on his, and missing on mine.
I've tried deleting Activity Monitor preferences to no avail, and of course I've resized the window and made sure it's not already showing off the edge of the window. It's like the column never existed.


jlbang
(101 rep)
Oct 5, 2022, 01:27 PM
2
votes
2
answers
4880
views
Manually Run Rosetta 2 on x86 Binary
I wrote a very simple C program and my goal is to build an x86-only binary and then run that binary on an Apple Silicon Mac and have Rosetta 2 translate it into a Universal 2 binary. I want to look at the Rosetta 2-translated binary specifically; I'm **not** looking to build a Universal 2 app myself...
I wrote a very simple C program and my goal is to build an x86-only binary and then run that binary on an Apple Silicon Mac and have Rosetta 2 translate it into a Universal 2 binary. I want to look at the Rosetta 2-translated binary specifically; I'm **not** looking to build a Universal 2 app myself (that would be trivial).
I attempted to run the program through Terminal (
$ ./helloworld
) and even stick it inside of a .app
, put it in the Applications folder, and double-click it. In both cases, the program runs correctly, but according to $ file helloworld
, the binary is still x86-only (Rosetta 2 didn't add an arm64 executable).
Any idea how to force Rosetta 2 to translate a binary?
nrubin29
(133 rep)
Nov 18, 2020, 10:00 PM
• Last activity: Nov 9, 2021, 07:44 PM
0
votes
0
answers
224
views
Thin universal application recursively
I'm running on a 2017 macbook pro so I don't need arm64 architecture. I can thin the application manually by going to each executable and library and use `lipo` to extract the x86_64 architecture, but it's very time-consuming for applications with many frameworks/libraries embedded. Is there a softw...
I'm running on a 2017 macbook pro so I don't need arm64 architecture. I can thin the application manually by going to each executable and library and use
lipo
to extract the x86_64 architecture, but it's very time-consuming for applications with many frameworks/libraries embedded.
Is there a software or a way to thin universal application recursively? It need to:
- identify all files that are executables/libraries and contains both x86_64 and arm64 in the application bundle, and for each file:
- extract the x86_64 part of the file
- replace the original file with the thinned file
- preferably, restore the modified date of the folder containing the file
Note that the two solutions here does not answer my question because Monolingual does not thin frameworks and libraries inside the application bundle and Xslimmer is discontinued.
Joy Jin
(3043 rep)
Nov 2, 2021, 01:51 PM
2
votes
3
answers
801
views
Get a list of application binary types - Intel or Universal
I just upgraded to an M1 Mac mini and did a full migration (including applications) from a previous Intel Mac mini Time Machine backup. Now I want to see what Apps I have on the new machine that are purely Intel Apps and hence potential candidates for seeing if they now have a Universal Binary versi...
I just upgraded to an M1 Mac mini and did a full migration (including applications) from a previous Intel Mac mini Time Machine backup.
Now I want to see what Apps I have on the new machine that are purely Intel Apps and hence potential candidates for seeing if they now have a Universal Binary version. (Some apps, such as Affinity Photo were already Universal before the the upgrade)
I know that I can go through each application one by one in the Finder and manually get this information, but is there an easier/automated way of doing it. Basically I just want a list of application names and the application type (Intel or Universal).
Peter M
(880 rep)
May 14, 2021, 12:09 PM
• Last activity: Aug 8, 2021, 06:48 PM
3
votes
2
answers
600
views
Is there any free solution to remove unneeded architectures from Universal ppc/intel binaries?
I am aware about an application that is able to remove unneeded architectures from Universal binaries - [XSlimmer](http://www.xslimmer.com/). Still, I am looking for a free solution for this because I am not willing to pay for this kind of service.
I am aware about an application that is able to remove unneeded architectures from Universal binaries - [XSlimmer](http://www.xslimmer.com/) .
Still, I am looking for a free solution for this because I am not willing to pay for this kind of service.
sorin
(31160 rep)
May 29, 2011, 08:42 AM
• Last activity: Dec 31, 2020, 08:16 AM
1
votes
1
answers
123
views
Saving space by thinning universal intel/arm binaries
I have no ARM CPUs on any of my laptops or desktops. If ever I get a computer new enough, it will already have all the binaries it needs or will get them from updates. So there is no justification for them to consume 90 GB¹ on my internal drive. I can reclaim that space by disabling SIP, using...
I have no ARM CPUs on any of my laptops or desktops. If ever I get a computer new enough, it will already have all the binaries it needs or will get them from updates. So there is no justification for them to consume 90 GB¹ on my internal drive.
I can reclaim that space by disabling SIP, using
ditto
to thin them while copying to somewhere else, copying them back where they belong, and re-enabling SIP. Pretty clumsy to have to do after **every** software update. Is there a better way?
¹assuming an ARM binary is about the same size as an Intel.
WGroleau
(5370 rep)
Dec 30, 2020, 10:46 PM
• Last activity: Dec 31, 2020, 08:16 AM
2
votes
2
answers
2555
views
How to tell if dmg file contains universal binaries, i.e. if it has been compiled for arm64 hardware
Can you tell from a `.dmg` file if it contains arm64 binaries? I've got a Mac mini M1 running Big Sur. I don't want to run apps under Intel, only arm64. I don't even have Rosetta installed, and want to avoid installing it. I can install apps, try to run them, and see if they request Rosetta installa...
Can you tell from a
.dmg
file if it contains arm64 binaries?
I've got a Mac mini M1 running Big Sur. I don't want to run apps under Intel, only arm64. I don't even have Rosetta installed, and want to avoid installing it.
I can install apps, try to run them, and see if they request Rosetta installation. But I'd like to know if the .dmg
file contains binaries compiled for arm64 without running the application.
Klas Mellbourn
(957 rep)
Dec 11, 2020, 01:38 PM
• Last activity: Dec 11, 2020, 05:42 PM
0
votes
1
answers
825
views
can’t link C++ code to .dylib in Xcode 12.2 (release build only)
I recently upgraded from Xcode 12.1 to 12.2, on macOS Catalina 10.15.7. My C++ project (which uses OpenCV) compiled without problem with Xcode 12.1. After the upgrade I get a lot of these: `ld: warning: ignoring file /usr/local/Cellar/opencv/4.5.0_5/lib/libopencv_gapi.dylib, building for macOS-arm64...
I recently upgraded from Xcode 12.1 to 12.2, on macOS Catalina 10.15.7. My C++ project (which uses OpenCV) compiled without problem with Xcode 12.1. After the upgrade I get a lot of these:
ld: warning: ignoring file /usr/local/Cellar/opencv/4.5.0_5/lib/libopencv_gapi.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
(I would have been unable to work but luckily I noticed that changing the “My Mac” *Scheme* to use *Debug* instead of *Release* for *Build Configuration* allows it to build without issue. Just runs much slower.)
My web searching suggests this might be related to “universal binary” compilation? Apparently the Apple approved solution is to wait for OpenCV to release a “universal binary” version of the .dylib? Until then:
- is there a way to say that, for now, I only care about the x86_64 machine I am
developing on?
- is it possible to roll back to Xcode 12.1?
Craig Reynolds
(123 rep)
Dec 6, 2020, 07:19 PM
• Last activity: Dec 6, 2020, 08:07 PM
3
votes
1
answers
4171
views
Terminal vs Shell vs Processes on ARM (Apple Silicon)
How does Big Sur and ARM (Apple) silicon handle the following permutations? Say I run Terminal as `x86_64` using `Rosetta2`, then does that mean I *must* use a `x86_64 shell`? If indeed I use an `x86_64` shell, can it only execute `x86_64` processes or `Universal` bins? Similarly, if I use a native...
How does Big Sur and ARM (Apple) silicon handle the following permutations?
Say I run Terminal as
x86_64
using Rosetta2
, then does that mean I *must* use a x86_64 shell
?
If indeed I use an x86_64
shell, can it only execute x86_64
processes or Universal
bins?
Similarly, if I use a native Apple Silicon Terminal, does it mean I must run an ARM shell?
I hope what I'm asking makes sense.
I ask as really what I'd like to do is use Home-brew a certain way. I want to use an ARM version of iTerm2 (Universal binary), then run latest ZSH
(may be x86_64
depending on what version brew installs, then also use a mix of ARM and Intel binaries.
Woodstock
(1376 rep)
Nov 18, 2020, 07:57 PM
• Last activity: Nov 18, 2020, 09:15 PM
23
votes
1
answers
21528
views
Why does `arch` output `i386`?
When I run `$ arch` on my 10.9 2012 MacBook Pro, I get the output i386 The manpage for `arch` says that the arch command is 2-way universal, 32-bit only However, `$ file "$(which arch)"` gives /usr/bin/arch: Mach-O universal binary with 2 architectures /usr/bin/arch (for architecture x86_64): Mach-O...
When I run
$ arch
on my 10.9 2012 MacBook Pro, I get the output
i386
The manpage for arch
says that
the arch command is 2-way universal, 32-bit only
However, $ file "$(which arch)"
gives
/usr/bin/arch: Mach-O universal binary with 2 architectures
/usr/bin/arch (for architecture x86_64): Mach-O 64-bit executable x86_64
/usr/bin/arch (for architecture i386): Mach-O executable i386
OTOH, python2.7
is running as a 64-bit executable:
$ /usr/bin/python2.7 -c 'import sys; print "%x" % sys.maxint'
7fffffffffffffff
Also, the kernel is apparently 64-bit:
$ file /mach_kernel
/mach_kernel: Mach-O 64-bit executable x86_64
uname
agrees:
$ uname -m
x86_64
..or does it?
$ uname -p
i386
intuited
(1062 rep)
Aug 1, 2014, 02:50 AM
• Last activity: Aug 2, 2014, 04:06 AM
1
votes
1
answers
107
views
Can my iPad open iPhone apps using the iPhone 5 form factor?
At the moment, my iPhone apps(for example: Yahoo Weather) on my iPad 3 Retina running iOS 7.0(11A465) are displayed using the 3.5" iPhone screen in the iPad, is it possible for me to change it to display the 4" iPhone screen(iPhone 5) in the iPad? Thanks.
At the moment, my iPhone apps(for example: Yahoo Weather) on my iPad 3 Retina running iOS 7.0(11A465) are displayed using the 3.5" iPhone screen in the iPad, is it possible for me to change it to display the 4" iPhone screen(iPhone 5) in the iPad?
Thanks.
Sani
(113 rep)
Feb 10, 2014, 03:29 AM
• Last activity: Feb 10, 2014, 07:13 AM
6
votes
1
answers
3932
views
Changing the type of an App to Universal App later in App Store?
Can I change the type of an submitted App in the App Store later? Initially I want to submit an iPhone only App, but later there might be an Universal App as well to support the iPad. Can this be submitted as an update to the existing App? So can the type of an App changed later?
Can I change the type of an submitted App in the App Store later? Initially I want to submit an iPhone only App, but later there might be an Universal App as well to support the iPad. Can this be submitted as an update to the existing App? So can the type of an App changed later?
powtac
(621 rep)
Jul 9, 2013, 01:38 PM
• Last activity: Jul 9, 2013, 03:04 PM
4
votes
2
answers
639
views
Lion: Switching an Application's launch preference off of Rosetta (PPC)
I have a case where a machine was upgraded to Lion. Prior to Lion the user was running Photoshop CS4 (a Universal Binary) under Rosetta which required hitting a checkbox in the application's "Get Info" dialog. With the advent of Lion and the removal of Rosetta, the checkbox is gone but the OS still...
I have a case where a machine was upgraded to Lion. Prior to Lion the user was running Photoshop CS4 (a Universal Binary) under Rosetta which required hitting a checkbox in the application's "Get Info" dialog. With the advent of Lion and the removal of Rosetta, the checkbox is gone but the OS still tries to run Photoshop as a PPC binary and fails.
Is there a way I can reset the "Launch this UB as a PPC binary" flag?
fbrereto
(295 rep)
Jul 26, 2011, 05:01 PM
• Last activity: Jul 26, 2011, 08:18 PM
Showing page 1 of 15 total questions