我正在使用稍微过时的 Xcode 版本(4.2.1,Apple clang 3.0 版),这可能是一个问题,但是.. 这应该可以工作:
我创建了一个新的 Quicklook 插件项目(“File > New > New Project”,然后是“System Plugin > Quick Look Plug-in”)
然后我重命名GeneratePreviewForURL.c
为GeneratePreviewForURL.m
(如Apple docs 中所述)
如果我尝试在文件中使用任何 Objective-C 代码,我会收到错误消息。例如,如果我将以下内容添加到GeneratePreviewForURL
方法中:
#include <Foundation/Foundation.h> // at start of file
NSMutableDictionary *blah;
[blah setValue:@"valuething" forKey:@"keything"];
我收到以下链接器错误:
Undefined symbols for architecture x86_64:
"_objc_msgSend", referenced from:
_GeneratePreviewForURL in GeneratePreviewForURL.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
导致问题的稍微修剪/重组的链接器命令是:
cd ~/QuicklookExample
setenv MACOSX_DEPLOYMENT_TARGET 10.7
/Developer/usr/bin/clang
-arch x86_64 -bundle
-isysroot /Developer/SDKs/MacOSX10.7.sdk
-L/snip -F/snip -filelist /snip/QuicklookExample.LinkFileList
-mmacosx-version-min=10.7
-framework QuickLook
-framework ApplicationServices
-framework CoreServices
-framework CoreFoundation
-o /snip/QuicklookExample