If you have already been using Xcode to build applications on a PowerPC-based Macintosh, you’ll see that building your code on an Intel-based Macintosh computer is accomplished in the same way. By default, Xcode compiles code to run on the architecture on which you build your Xcode project. Note that your Xcode target must be a native target.
Tip: CodeWarrior users can read Xcode from a CodeWarrior Perspective for a discussion of the similarities and differences between the two. This information can help you to put your CodeWarrior experience to work in Xcode.
When you are in the process of developing your project, you’ll want to use the following settings for the Default and Debug configurations:
Keep the Architectures settings set to $(NATIVE_ARCH).
Change the Mac OS X Deployment Target settings to Mac OS X 10.4.
Make sure the SDKROOT setting is /Developer/SDKs/MacOSX10.4u.sdk.
You can set the SDK root for the project by following these steps:
Open your project in Xcode 2.2 or later.
Make sure that your Xcode target is a native target. If it isn’t, you can choose Project > Upgrade All Targets in Project to Native.
In the Groups & Files list, click the project name.
Click the Info button to open the Info window.
In the General pane, in the Cross-Develop Using Target SDK pop-up menu, choose Mac OS X 10.4 (Universal).
If you don’t see Mac OS X 10.4 (Universal) as a choice, look in the following directory to make sure that the universal SDK is installed:
/Developer/SDKs/MacOSX10.4u.sdk
If it’s not there, you’ll need to install this SDK before you can continue.
Click Change in the sheet that appears.
The Debug build configuration turns on ZeroLink, Fix and Continue, and debug-symbol generation, among other settings, and turns off code optimization.
When you are ready to test your application on both architectures, you’ll want to use the Release configuration. This configuration turns off ZeroLink and Fix and Continue. It also sets the code-optimization level to optimize for size. As with the Default and Debug configurations, you’ll want to set the Mac OS X Deployment Target to Mac OS X 10.4 and the SDK root to MacOSX10.4u.sdk. To build a universal binary, the Architectures setting for the Release configuration must be set to build on Intel and PowerPC.
You can change the Architectures setting by following these steps:
Open your project in Xcode 2.2 or later.
In the Groups & Files list, click the project name.
Click the Info button to open the Info window.
In the Build pane (see Figure 1-1), choose Release from the Configuration pop-up menu.
Select the Architectures setting and click Edit. In the sheet that appears, select the PowerPC and Intel options, as shown in Figure 1-2.
Close the Info window.
Build and run the project.
If your application doesn’t build, see “Debugging.”
If your application builds but does not behave as expected when you run it as a native binary on an Intel-based Macintosh computer, see “Troubleshooting Your Built Application.”
If your application behaves as expected, don’t assume that it also works on the other architecture. You need to test your application on both PowerPC Macintosh computers and Intel-based Macintosh computers. If your application reads data from and writes data to disk, you should make sure that you can save files on one architecture and open them on the other.
Note: Xcode has per-architecture SDK support. For example, you can target Mac OS X versions 10.3 and 10.4 for PowerPC while also targeting Mac OS X v10.4 and later for Intel-based Macintosh computers.
For information on default compiler settings, architecture-specific options, and Autoconf macros, see “Build Options.”
For information on building with version-specific SDKs for PowerPC (Mac OS X v10.3, v10.2, and so forth) while still building a universal binary for both PowerPC and Intel-based Macintosh computers, see the following resources:
Using Cross Development in Xcode, in Xcode User Guide.
Cross Development and Universal Binaries in the Cross-Development Programming Guide provides details on to create executable files that contain object code for both Intel-based and PowerPC-based Macintosh computers.
Last updated: 2007-02-26