指定のアプリケーションファイルが32bitバイナリかどうかを判定するAppleScriptの改訂版です。
本Scriptシリーズは対象のアプリケーションが起動している状態で対象CPUアーキテクチャを判定するものではなく、起動していない状態で判定するものです。
PPC 32 / PPC 64 / Intel 32 / Intel 64 / ARM 64の各アーキテクチャの判定を行います。FAT Binaryの場合には複数のアーキテクチャが返ってきます。
▲本Scriptの応用例
AppleScript名:指定アプリケーションのバイナリアーキテクチャ判定 v3.scptd |
— – Created by: Takaaki Naganoya – Created on: 2020/08/18 — – Copyright © 2020 Piyomaru Software, All Rights Reserved — use AppleScript version "2.4" — Yosemite (10.10) or later use framework "Foundation" use scripting additions set anApp to choose file of type {"com.apple.application-bundle"} default location (path to applications folder) –set anApp to choose file default location (path to applications folder) set app32 to chk32Binary(anApp) of me –> {"PPC 32", "Intel x32"} on chk32Binary(anAlias) set aPOSIX to POSIX path of anAlias set aURL to current application’s |NSURL|’s fileURLWithPath:(aPOSIX) set aBundle to current application’s NSBundle’s bundleWithURL:aURL set F1 to (aBundle = missing value) as boolean if F1 is not equal to false then return calcIllegular(aPOSIX) of me set aDict to aBundle’s executableArchitectures() set F2 to (aDict = missing value) as boolean if F2 is equal to true then return calcIllegular(aPOSIX) of me set aList to (aDict’s valueForKeyPath:"stringValue") as list set arList to {} repeat with i in aList set j to contents of i if j = "7" then –NSBundleExecutableArchitectureI386 set the end of arList to "Intel 32" else if j = "18" then –NSBundleExecutableArchitecturePPC set the end of arList to "PPC 32" else if j = "16777223" then –NSBundleExecutableArchitectureX86_64 set the end of arList to "Intel 64" else if j = "16777234" then –NSBundleExecutableArchitecturePPC64 set the end of arList to "PPC 64" else if j = "16777228" then –NSBundleExecutableArchitectureARM64 set the end of arList to "ARM 64" end if end repeat return arList end chk32Binary on calcIllegular(aPOSIX) –Old Style Bundle for PPC set sRes to do shell script "file " & quoted form of aPOSIX if sRes contains "Mach-O executable ppc" then return {"PPC 32"} –NSBundleExecutableArchitecturePPC return missing value end calcIllegular |