Making Xcode Projects for Mac OS

This page describes the process for moving your Metrowerks CodeWarrior project to an Apple Xcode project.

For more information on this topic, please see the documentation found on the Apple web site: http://developer.apple.com

Note:
The samples here use the specific project 'simpleformat'. Substitute your project names for 'simpleformat'.

Requirements

  • The required development environment for this conversion is Apple Xcode Version 3.1.2
  • The system requirement is Mac OS X Version 10.5.8

Create the New Project

  1. From the Xcode menus choose File and then New Project.
  2. From the Bundle section choose Carbon Bundle.
  3. Click Next.
  4. Type in your project name and location.
    • Project name: simpleformat
    • Project Directory: ../samplecode/format/simpleformat/mac/simpleformat/
  5. Click Finish.

Project Clean Up

  1. Remove the InfoPlist.strings file from Resources.
    (Choose Delete references and files from the dialog.)
  2. Remove main.c.
    (Choose Delete references and files from the dialog.)

Moving the Project

Xcode makes a new folder and puts the project there. I want things up a level to be consistent with my windows environment.

Note:
You can skip this step for your projects. Please make a note of your level change when using the relative paths later in this document.
  1. Close project and navigate to location. We want it up a level.
  2. Select the project file (simpleformat.xcodeproj).
  3. Select the Info.plist.
  4. Select the pre compiled header (simpleformat_Prefix.pch).
  5. Move them up a level (../samplecode/format/simpleformat/mac).
  6. Delete the simpleformat folder that the files where copied from.

Add Files to the Project

  1. Open the project from the new location.
  2. Add FlatCarbon (/Developer/Headers/FlatCarbon).
    Use drag and drop from finder.
  3. Add the Photoshop SDK photoshopapi headers from ../photoshopapi/
    Use drag and drop from finder.
    Remove stuff you don't need, (adm, c++wrapperclasses, etc...)
    OR
    Only add the files that you need.
  4. Add the Photoshop SDK Common headers and resources from ../samplecode/common/
    Use drag and drop from finder.
    Remove stuff you don't need, (resources mostly)
    OR
    Only add the files that you need.
  5. Add your project specific files (headers, sources, and resources)

Fix the Output Folder

  1. Click the main project group (simpleformat).
  2. Click info.
  3. Click on the 'build' configuration.
  4. Select all settings.
  5. Change Build Products Path to (../../../Output/Mac).

Add a Task to the 'Targets'

  1. Go down to 'Targets' and select 'simpleformat'.
  2. Right click select Add -> New Build Phase -> New Build ResourceManager Resources Build Phase.
  3. Close the window that pops open.
  4. Find your project .r files that you added.
  5. Select them one in turn and make sure the checkbox is selected for including in the build process.
  6. You should see the file number increase each time you add one.
  7. Do the same to Info.plist.

Edit Info.plist

This file needs to be edited to be the type of plug-in you are working on.

Fix the Rez Prefix File

  1. Click the main project group (simpleformat).
  2. Click info.
  3. Click on the 'build' configuration.
  4. Select all settings.
  5. Search for 'Rez'.
  6. Change Rez Prefix File to (/../../../common/includes/MachOMacrezXcode.h).

Some Other Useful Info

  • Xcode defines: use __APPLE_CC__ for compiling with Xcode, use __LP64__ for compiling on MacTel 64 bit machines, use __i386__ for compiling on MacTel 32 bit binaries
  • Dissolve is the only example working for MacIntel
  • Xcode project settings can be fun. Make sure you are at the right level during edits. More information can be found here. Project Settings Info
  • Use "lipo -detailed_info YourPluginName" to see what kind of binary you have. You will need to navigate inside the package to the actual plug-in.
  • Use "nm -g YourPluginName" to see what functions you have exported. You must have your main function exported. Something like T _PluginMain.

Another option -- Use the import option in Xcode

Another option is to use the File->Import Project... Follow the instructions from the Xcode dialogs during the conversion process. Also, see the documentation and help on the Apple Developers web site for more information on using this feature.