Background
I’m learning Objective-C and Cocoa, and I thought creating simple programs to answer my needs would be a nice thing. I already have a solid .NET C# background, some Python knowledge, and a little of C.
One of my “simple first app” I tried to do is a simple QuickLook plug-in for Arduino‘s sketch files. I thought it would be a simple task to accomplish since these files are plain text C-like scripts, the only “different” thing is they have a .pde extension.
I uploaded the project on GitHub at ArduinoQuickLook as a reference (the first commit contains a vanilla Xcode 4.1 QuickLook plugin-project).
What I found
Looking around the net I found these resources:
What are my problems
-
Both of them use GeneratePreviewForURL.m and GenerateThumbnailForURL.m files, but when I created the project in Xcode 4.1 it created GeneratePreviewForURL.c and GenerateThumbnailForURL.c (note .c instead of .m).
-
Both QLStephen and QLColorCode use
#import <Foundation/Foundation.h>in their GeneratePreviewForURL.m and GenerateThumbnailForURL.m files, but if I try to#importit it yields to many errors. (Maybe because my files are .c instead of .m?) -
It’s not clear to me how I declare which files my plug-in will handle, I understood I need to change ArduinoQuickLook/ArduinoQuickLook-Info.plist (row 14) but what I have to write there? Something like
cc.arduino.pde?
This tutorial on creating a Quicklook plugin explains things nicely, but to summarise:
Point 1 and 2 are related – for some strange reason the Quicklook plugin template only contains
.cfiles – as such, importing the Obj-CFoundation.hheader causes errors.You should just be able to rename the files from
.cto.mand it will work as expected.You need to do two things – one is say which UTI (Uniform Type Identifier) your plugin handles (e.g
cc.arduino.pde), by changing the line you mention:…but you also have to describe that UTI (mostly so it can map the file-extension to that UTI)
There are two slightly different ways to declare UTI’s, [as “Declaring New Uniform Type Identifiers”] describes:
For a Quicklook plugin, you probably want an “imported” UTI declaration, in which you would add something like this to your Info.plist: