Assuming that the application meets the criteria described in “What Can Be Translated?,” applications that have only a PowerPC binary automatically run as translated on an Intel-based Macintosh. For testing purposes, there are several ways that you can force applications that have a universal binary to launch as a PowerPC binary on an Intel-based Macintosh:
For applications, “Make a Setting in the Info Window”
For command-line tools “Use Terminal”
For an application that you are writing, “Modify the Property List”
Programmatically, “Use the sysctlbyname Function”
Each of these methods is described in this section.
You can manually set which binary to execute on an Intel-based Macintosh computer by selecting the “Open using Rosetta” option in the Info window of the application. To set the option, click the application icon, then press Command-I to open the Info window. Make the setting, as shown in Figure A-1.
You can force a command-line tool to run translated by entering the following in Terminal:
ditto -arch ppc <toolname> /tmp/toolname |
/tmp/toolname |
You can set the default setting for the “Open using Rosetta” option by adding the following key to the Info.plist of your application bundle:
<key>LSPrefersPPC</key> |
<true/> |
This key informs the system that the application should launch as a PowerPC binary and causes the “Open using Rosetta” checkbox to be selected. You might find this useful if you ship an application that has plug-ins that are not native at the time of shipping.
The exec_affinity routine in Listing A-2 controls the preferred CPU type for sublaunched processes. You might find this routine useful if you are using fork and exec to launch applications from your application.
The routine calls the sysctlbyname function with the "sysctl.proc_exec_affinity" string, passing a constant that specifies the CPU type. Pass CPU_TYPE_POWERPC to launch the PPC executable in a universal binary. (For information on sysctlbyname see Mac OS X Man Pages.)
Listing A-2 A routine that controls the preferred CPU type for sublaunched processes
cpu_type_t exec_affinity (cpu_type_t new_cputype) |
{ |
cpu_type_t ret; |
cpu_type_t *newp = NULL; |
size_t sz = sizeof (cpu_type_t); |
if (new_cputype != 0) |
newp = &new_cputype; |
if (sysctlbyname("sysctl.proc_exec_affinity", |
&ret, &sz, newp, newp ? sizeof(cpu_type_t) : 0) == -1) { |
fprintf(stderr, "exec_affinity: sysctlbyname failed: %s\n", |
strerror(errno)); |
return -1; |
} |
return ret; |
} |
Last updated: 2007-02-26