I’ve put together an Xcode template for creating Universal Binary Mach-O plugins for REALbasic. The template will compile a dylib for PPC, and a bundle for Universal Binary – and put these in a plugin folder ready for conversion to a .rbx file.
Updated 3/10/08 for version 1.4 of the template.
Updated 8/1/07 for version 1.3 of the template.
Updated 26/8/06 for version 1.2 of the template.
Updated 23/8/06 for version 1.1 of the template.
To use this template, start by downloading my template files (.zip format, 27KB), and unzip the downloaded template files archive.
Then, do the following:
- Make sure you have Xcode installed. You can download it for free from Apple by signing up for a free Apple Developer Connection Online membership. This template has been tested with Xcode 3.1.1. When you install Xcode, be sure to install the “Mac OS X 10.3.9 package” (it isn’t selected by default), or the plugin template won’t work.
- Make sure you are using REALbasic 2006r4 or later for Mac OS X. 2006r4 was the first version to support Universal Binary builds, and so you’ll need this version or later to test your Universal Binary plugin.
- Make sure you use the latest REALbasic Plugin SDK (included in the REALbasic download for Mac OS X, in the “/Extras/Plugins SDK/” folder).
- Copy the folder “REALbasic”, from the downloaded template files, to “/Developer/Library/Xcode/Project Templates/” (which is where Xcode keeps its project templates).
- Launch Xcode.
- Select “File > New Project…”.
- Select the REALbasic category under the Mac OS X category, and then select the “REALbasic Universal Binary Mach-O Plugin”. Click “Choose…” to use this template.
- Give the project a name. This will also be the name of your plugin, and the folder the project lives in. By default the new folder will be created in your home folder, but you can change this to another location.
- Click “Finish”. A new project will open, and a new project folder will be created on your hard disk, wherever you chose above.
- Find this folder on your hard disk, and copy the “Glue Code” and “Includes” folders from the latest Plugins SDK into the root level of your new project’s folder. Switch back to Xcode, and you should see that the “Glue Code” and “Includes” folders and files in the Xcode file list have turned from red text to black text.
- By default, the plugin contains one global method, called CurrentArchitecture. You can now compile your plugin, and give this method a test! Just select “Build > Build” in Xcode (or press Apple-B), and both the PPC and Universal Binary dylibs will be built.
- The first time you build the project, you will get four warnings that build folders do not exist. Ignore these warnings – they’re just caused by Xcode creating the folder structure for your plugin.
- Once you have built the empty plugin, you’ll find that a new folder will have be created by Xcode in your project folder. It will have the same name as the project. This folder is the skeleton structure of your plugin. It will contain one folder, called “Build Resources”. “Build Resources” will contain two folders: “Mac Carbon Mach-O”, containing the PPC dylib, and “Mac Carbon Mach-O Universal”, containing the Universal Binary bundle.
- To make these two files into a plugin (also known as a .rbx file), you’ll need to use the “Plugin Converter” from the REALbasic Plugins SDK. Open the “Plugin converter.rb” project, and build the project. This will build an application called “RB Plugin Converter”.
- Run this application, and click on the “Convert Folder” button. Find your project folder, and select the subfolder with the same name (you’re selecting the folder that contains the “Build Resources” folder). Click on “Choose”.
- The Plugin Converter will prompt you to select where you want to save the built plugin. Select your REALbasic Plugins folder (something like “/Applications/REALbasic 2008r4/Plugins/”, and click “Save”. A file called “YourProjectName.rbx” will be created in the Plugins folder. This is your plugin!
- Your plugin is now ready to go. Launch REALbasic, open the sample project included with the template download – “PluginTest.rbp” – and build the project. It will build as a Universal Binary application called “PluginTest.app”. If you run “PluginTest.app” on a PowerPC Mac, it will use the CurrentArchitecture global method to display a message saying that it is running the PowerPC code. The same goes for if you run the app under Rosetta on an Intel Mac. If you run “PluginTest.app” natively on an Intel Mac, then it will say it is running the Intel plugin code.
- Once you have finished developing and testing your plugin, switch Xcode to use the “Deployment” build configuration. You can do this from Xcode’s “Project > Set Active Build Configuration” menu. Build the plugin again. The Deployment build configuration strips out any unused code and symbols, and results in a much smaller plugin file. Use this version of the plugin in any applications you distribute.
Version 1.4, 3/10/08
Updated the instructions for REALbasic 2008r4 and Xcode 3.1.1.
Version 1.3, 8/1/07
Changed the Universal Binary part of the plugin to be a bundle rather than a dynamic library. This will take advantage of a new feature in future versions of REALbasic, where the Universal Binary part of the plugin will be loaded directly into memory and not written out to disk.
Changed the target order to ensure that “Build All” is the default.
Version 1.2, 26/8/06
Added in an exports file to the Deployment build configuration for both PPC and UB, and set this build configuration to use Dead Code Stripping. This reduces the size of the built Deployment plugin considerably.
Changed the SDKs and Mac OS X Deployment Targets to build for 10.3.9 with GCC 3.3 for the PPC target and the PPC part of the UB target; and to build for 10.4u with GCC 4.0 for the i386 part of the UB target. This means that 10.3 can be supported for backwards compatability.
Disabled Prebinding for the i386 part of the UB target, as it is 10.4 only and therefore doesn’t need prebinding.
Removed the unused “Default” build configuration.
Version 1.1, 23/8/06
The PowerPC dylib is now built as a PowerPC target when compiled on an Intel machine. Previously it was being compiled as $(NATIVE_ARCH), which would build as PPC on PPC, and Intel on Intel. Thanks to Philippe Rigaux for spotting this error.
The UB dylib now compiles against the 10.4u SDK, at /Developer/SDKs/MacOSX10.4u.sdk/. This means that it will actually compile :-)
A sample global method, CurrentArchitecture, is now included in the plugin template.
A few other compile settings have been moved from being Target settings to being Project settings, to avoid duplication.
Version 1.0, 21/8/06
Initial release.