2012-05-03 56 views
3

我需要比较软件包的体系结构并将其与安装程序的机器体系结构进行比较;如果它们匹配,则安装将继续,否则它将中止。 使用宏可以轻松获得体系结构;我想知道是否有方法检查要安装的软件包的体系结构。OSX软件包体系结构

回答

0

这将决定当前应用程序(或任何束被判定为mainBundle)与目标包共享一个共同的架构。需要Mac OS X 10.5 for NSBundle的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 
} 
1

从贝,你可以做

otool -hv <path to mach-o image> 

图像通常是在应用Contents/MacOSVersions/Current在框架