D for Xcode
Download
-
D plugin for Xcode 1.0.1 (828 Kb)
- Most recent update of the D plugin for Xcode. November 23, 2007.
-
Source code 1.0.1 (1.5 Mb)
- Source code for building the plugin on your own.
Note: This plugin is only for Xcode versions 2.4.1 and 2.5. (Xcode 2.5 can be installed side by side with Xcode 3 on Mac OS X 10.5 Leopard.)
Introduction
This D plugin for Xcode makes it easy to develop tools, libraries, and applications in the D programming language using Apple’s Xcode IDE. The plugin does the following things:
It adds to Xcode the GDC D compiler and the appropriate build rules so that D source files are recognised and are as easy to compile as C, C++, and Objective-C ones. Once you’ve added a D source file to a project or target, options specific to the D compiler will apear in the build settings.
It allows Xcode to track dependencies between files (by looking for
importdeclarations) and automatically recompile files when a dependency has been modified.It allows the Xcode debugger to work with D files: setting breakpoints and stepping thru the code works as you’d expect it.
It provide “perfect” syntax highlighting using the lexer from Digital Mars’ D front end.
It populates the Code Sense editor function popup with functions, classes, and some other constructs the D front end parser can find in your D source file.
It provide icons for .d and .di files in the Finder and elsewhere on the system, and it allows D files to open with Xcode by default. On Mac OS X 10.5 Leopard, D files are opened in Xcode 2.5 since this plugin does not support Xcode 3.
Requirements
- Mac OS X 10.4 with Xcode 2.4.1 or 2.5
- Mac OS X 10.5 with Xcode 2.5
Note: This plugin hasn’t been tested with Xcode 3 and is not expected to work.
Installation
- For Xcode 2.4.1:
- Take the downloaded “D for Xcode.xcplugin” file to the “/Library/Application Support/Apple/Developer Tools/Plug-ins” folder (create the folder if you need to), and relaunch Xcode.
- For Xcode 2.5:
- Take the downloaded “D for Xcode.xcplugin” file to the “/Library/Application Support/Developer/2.5/Xcode/Plug-ins” folder (create the folder if you need to), and relaunch Xcode.
Alternatively you can install the plugin in the Library folder in your own user account.
Once this is done, you can create D files and add them to the desired targets in your Xcode projects, and they should compile and link fine.
Screenshots
Known Issues
- Compiling with a SDK under Xcode 2.4.1 generates an innocuous missing directory warning when linking. You can add an empty directory at the specified path in the SDK to remove that warning, or you can upgrade to Xcode 2.5 which seem to no longer exhibit this behaviour.
Crash Workaround (if you need it)
D for Xcode adds a full D parser running within the Xcode process. This means that if something goes wrong when parsing your file, it has the potential to crash Xcode. While I’ve made all efforts I could to avoid that situation, you may still prefer to disable it if you experience crashes. So if you ever need to disable real-time syntax highlighting and code parsing (for the editor pop-up menu), here’s how to do it.
Open the plugin package by control-clicking or right-clicking on the plugin file from the Finder to open the contextual menu, and choose “Show Package Content”. From there, open the “Resources” folder and the “d.pblangspec” file in a text editor. Near the start of the file, you’ll see these two lines:
SourceScannerClassName = DXDSourceScanner;
SourceLexerClassName = DXDSourceLexer;
Comment them out (by adding // at the start of each line) and relaunch Xcode. This will prevent Xcode from invoking the parser built in the plugin, but shouldn’t affect the build process. Syntax highlighting will default to using the Xcode built-in lexer with custom rules which can’t keep track of everything in D, but is still good enough for most cases.
About Module Directories
The compiler and the dependency checker assumes the module directory you’re working with is the directory project directory. This means that a module named mypackage.mymodule must be located at PROJECT_DIR/mypackage/mymodule.d. You can add other module directories (if you want to include libraries for instance), but the dependency graph doesn’t take them into account and your files depending on them won’t be recompiled automatically if you change them (you’ll need to clean the target first). Let me know if this is a problem for you.
Bug Reports
If you find a problem, whether it’s crashing Xcode or not, I’d like to know about it. Please give me any relevant information (such as Xcode crash logs if Xcode crash) and the appropriate steps, or files, to replicate the problem (so I can debug it locally). You can send bug reports at this address: michel.fortin@michelf.com.
License
D for Xcode is available under the GNU General Public License, version 2 or later.
Version History
D for Xcode 1.0.1 (November 23, 2007)
- The plugin now registers its launcher application when loaded into Xcode. Previously it was counting on the Finder to register it while copying the plugin, but that isn’t always reliable; hence the need for a backup plan.
D for Xcode 1.0 (November 20, 2007)
- First non-beta release.

