The Dashboard is a bit of a web developer’s paradise - standards-based code with only one browser required for development and testing. Plus, the use of web plug-ins as well as system level scripting languages (AppleScript, Ruby, Perl, etc.). The possibilities are almost endless really.
Creating widgets for the Dashboard isn’t really that hard, but there are a handful of useful things to know before you get started and I’ll try to outline a few that will hopefully save a bit of debugging and gray hairs along the way.
- RTFM. Read the developer documentation. No, seriously there’s good, useful information in there.
- Always, always, always have a default image in the main directory of your widget. Name it
Default.png. It gets used as the drag image when a user decides to try your fancy new widget in the Dashboard.
- Create a
version.plistfile and keep it up to date if you modify your widget.
- Be sure to create an Icon for your widget to show in the Widget Bar. Name the file
Icon.pngand keep it in the main directory of your widget bundle.
- Test your widget in Safari during development and keep an eye on the Console for debugging messages.
- Download my Dashboard Widget Xcode Template (Works in Xcode 1.x and above, so yes, it works on Panther). Decompress the archive and place the contents in a new folder called
Dashboardunder this path:
/Library/Application Support/Apple/Developer Tools/Project Templates/
The template will do a lot of the preliminary work for you. It creates the base HTML, CSS and JS files along with the necessary property list XML files - and will automatically modify certain properties in and of those files based on the name you give the project.
Info.plist file contains all the current allowed properties for a widget. Disable or remove as necessary, but they’re all there to save you looking them up in the documentation.
Well… what are you waiting for? Let’s see those widgets!