OSX Bundle Architecture

I need to compare the architecture of the package and compare it with the architecture of the machines from the installer; if they coincide with the installation, it will continue otherwise, it will be interrupted. Getting architecture is easy with macros; I would like to know if there is a way to test the architecture of the package being installed.

+3
source share
2 answers

This will determine if the current application (or any bundle defined as mainBundle) uses a common architecture with the target package. Requires Mac OS X 10.5 for the NSBundle method executableArchitectures.

NSArray *targetArch = p[NSBundle bundleWithPath:@"/path/to/bundle.bundle"] executableArchitectures];
NSArray *thisArch = [[NSBundle mainBundle] executableArchitectures];

if ([targetArch firstObjectInCommonWithArray:thisArch])
{
    // target bundle has architecture which matches current application
}
0
source

From the shell you can do

otool -hv <path to mach-o image>

Images are usually found Contents/MacOSin applications or Versions/Currentwithin

+1
source

All Articles