Home Archives
 

Today's Date

Tuesday February 07, 2012

Friends & Family

Stock Quotes

Latest Joy of Tech

Latest Joy of Tech!
An Applet to Test An Application for Intel/68K/PPC/Universal Code Print E-mail
Friday, 30 June 2006 00:01

This is an applet that I came up with to test an application to see whether it will run natively on PPC or Intel Macs.

Copy and paste the code into the Script Editor and save it as an application. (Be careful of line-breaks!) You can then drop any application-icon onto the applet's icon and it will tell you whether the application is ppc, i386 or universal.

It only works on OS X applications, but the error that it generates when you drop a Classic application on it is informative in that any application old enough to confuse it will probably not run natively on an Intel Mac.

The output looks something like this:

 

ppcinteltest.jpg

Here's the code:

on open dropped_file

set dropped_file to dropped_file as alias
set file_name to (name of (info for dropped_file))

if kind of (info for dropped_file) does not contain "Application" then
display dialog "This program only works with Applications!" buttons {"Ok"} default button 1
error number -128
end if

if kind of (info for dropped_file) contains "Classic" then
display dialog file_name & " is a 68k Classic Application." buttons {"Ok"} default button 1
error number -128
end if

--
-- Procedure for testing compiled binaries...
--

if package folder of (info for dropped_file) is false then
set app_path to quoted form of POSIX path of dropped_file as list

-- Test for that error with FAT apps...

try
(do shell script "lipo -info " & app_path)
on error TheError
display dialog file_name & " is probably fat 68k/PPC, but I can't be certain." buttons {"Ok"} default button 1
error number -128
end try


set app_kind to (do shell script "lipo -info " & app_path)
set AppleScript's text item delimiters to {" "}

if (app_kind contains "PPC") and (app_kind contains "i386") then
set app_is to "universal"
else
set app_is to (last text item of app_kind)
end if

display dialog file_name & " is a " & app_is & " application." buttons {"Ok"} default button 1
error number -128
end if

--
-- Procedure for testing application packages...
--

if package folder of (info for dropped_file) is true then
set app_path to POSIX path of dropped_file

tell application "System Events"
if exists file ((path of dropped_file as Unicode text) & "Contents:Info.plist") then
set short_name to value of (property list item "CFBundleExecutable" of property list file ((path of dropped_file as Unicode text) & "Contents:Info.plist"))
else
if exists file ((path of dropped_file as Unicode text) & "Contents:Info-macos.plist") then
set short_name to value of (property list item "CFBundleExecutable" of property list file ((path of dropped_file as Unicode text) & "Contents:Info-macos.plist"))
end if
end if
end tell

set true_app_path to quoted form of (app_path & "Contents/MacOS/" & short_name)

-- Test for that error with FAT apps...
try
(do shell script "lipo -info " & true_app_path)
on error TheError
display dialog file_name & " is probably fat 68k/PPC, but I can't be certain." buttons {"Ok"} default button 1
error number -128
end try

set app_kind to (do shell script "lipo -info " & true_app_path)
set AppleScript's text item delimiters to {" "}

if (app_kind contains "PPC") and (app_kind contains "i386") then
set app_is to "universal binary"
else
set app_is to (last text item of app_kind)
end if

display dialog file_name & " is a " & app_is & " application." buttons {"Ok"} default button 1
error number -128
end if

end open

Comments

No comments have been added yet. Be the first to comment...

Add a New Comment

 
 
 
 
 
 
Joomla Templates by Joomlashack