Making a 64 bit Macintosh plug-in for Photoshop

This page describes the process for creating a 64 bit Macintosh plug-in for Photoshop.

Here is a list of the items needed to build and test a 64 bit Macintosh plug-in. This documentation will focus on updating the Dissolve filter example for 64 bit. All projects in the SDK have a 64 bit output option. Refer to the specific plug-in type for more information.

  • Adobe Photoshop CS5 Macintosh
  • Adobe Photoshop CS5 SDK
  • Xcode 3.1.2
  • Macintosh OS X 10.5 or higher

Step 1: Find portability issues

The majority of the problems you will deal with when converting from 32 bit to 64 bit are assumptions made about the size of a pointer. There is a lot of code that puts a pointer ( 4 or 8 bytes ) into an int or long ( 4 bytes only ). As you can see, that will no longer work in the 64 bit environment. The second biggest problem is using the wrong type when getting the size of information. The new operator and many size operators return a size_t type ( 4 or 8 bytes ) and are assigned to int ( 4 byte ) values or long ( 4 or 8 bytes).

  • size_t is 4 or 8 bytes
  • int is 4 bytes
  • long is 4 or 8 bytes (Windows is 4 bytes only)
  • pointer is 4 or 8 bytes
  • intptr_t is 4 or 8 bytes

Step 2: Switch to the 10.5 SDK from Apple

It is recommended to use the 10.5 SDK from Apple. Switch to the 10.5 SDK by clicking on your Plug-in in the Targets section of your project. Select "Get Info" and then select the "Build" tab. Make sure that "Mac OS X 10.5" is selected in the Base SDK section.

Use105SDK.jpg

Step 3: Add 64 bit configurations to your project

Select your main project and then "Get Info". Click on the configurations tab. Select your Debug target and then click the Dupulicate button at the bottom to clone this target to a new one. Use Debug_x86_64 as the new configuration name.

Add64BitTargets.jpg

Step 4: Change to 64 bit architecture for new configuration

Switch to the 64 bit architecture by clicking on your Plug-in in the Targets section of your project. Select "Get Info" and then select the "Build" tab. Make sure that "X86_64" is selected in the Architectures section.

ChangeArchMac.jpg

Step 3: Fix entry point and PiPL

The main entry point to the plug-in needs to be changed.

// --------------------------------------
// The old entrypoint
// --------------------------------------
DLLExport MACPASCAL void PluginMain(
  const int16 selector, 
  void * filterRecord, 
  int32 * data, 
  int16 * result)

// --------------------------------------
// Thew new entrypoint
// using the dynamic type intptr_t 
// --------------------------------------
DLLExport MACPASCAL void PluginMain(
  const int16 selector, 
  void * filterRecord, 
  intptr_t * data, 
  int16 * result)

The PiPL property needs a 64 bit selector. Here is the recommended PiPL properties for all platforms:

#ifdef __PIMac__
    #if (defined(__x86_64__))
        CodeMacIntel64 { "PluginMain" },
    #endif
#else
    #if defined(_WIN64)
        CodeWin64X86 { "PluginMain" },
    #else
        CodeWin32X86 { "PluginMain" },
    #endif
#endif

Step 4: Test

Adobe Photoshop CS5 installs as a universal binary with i386 and x86_64 as the two binaries inside. Depending on your operating system the correct binary will launch. It is recommended to test on both a 64 bit operating system and a 32 bit operating system.

Other Issues

Only the Dissolve example has been converted to a Cocoa UI and all the projects noted above. All of the other examples have had their UI removed on the 64 bit Macintosh Platform. Use the Dissolve example to see how to hook up a UI on 64 bit Macintosh to a plug-in. All of the other plug-ins are default configured to make a Universal Binary for i386 and x86_64. Use the __LP64__ compile flag to determine that the target is 64 bit.

Online Information

Watch out for Objective-C naming conflicts. Please use a unique id for all of your Objective-C code names as described here. See this for more information: Preventing Name Conflicts

Finding the Version info in Xcode

From the Xcode menu select About Xcode
Version 3.1.2
Component versions
Xcode IDE: 1149.0
Xcode Core: 1148.0
ToolSupport: 1102.0