Reputation: 12167
I've got an app, written in Obj-C. The info.plist has a list of file types that the app can open. I'm pretty sure that this is working because when I try to drag a file of an unacceptable type, the app doesn't highlight, but when I drag a file of an acceptable type, it does highlight, and lets me drop.
When I drop, the app starts up, correctly, however, then I get a dialog saying:
The document "foo.tiff" could not be opened. DocView cannot open files in the "TIFF File" format.
I DO have this in my info.plist
<key>CFBundleTypeExtensions</key>
<array>
<string>tif</string>
<string>tiff</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>TIFFFile.icns</string>
<key>CFBundleTypeName</key>
<string>TIFF File</string>
<key>CFBundleTypeOSTypes</key>
<array>
<string>TIFF</string>
</array>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>LSHandlerRank</key>
<string>Documents/</string>
Thanks.
Upvotes: 5
Views: 3057
Reputation: 97
Just another thing that sometimes gets me is that you need to include $(PRODUCT_MODULE_NAME). before your class name. If you use the pulldown menu in 10.2.1 in a Swift project Xcode doesn't seem to put a fully qualified name for your class in that field. In prior versions it did.
I also suspect, but haven't proven that the class and any classes the document inherits need to be Public or Open.
Upvotes: 0
Reputation: 22707
First, the part of the Info.plist that you show is within the CFBundleDocumentTypes array, not at the top level of the Info.plist, right?
Second, under LSHandlerRank you have Documents/, which is not a legal value, nor is Documents.
Third, you probably need to add NSDocumentClass.
Upvotes: 2
Reputation: 9543
Does your app actually handle the file opening?
If it's an NSDocument
application, you need to implement one of the file reading methods such as readFromData:ofType:error:
. In an ordinary NSApplication your app delegate should handle it in application:openFile:
. In both cases you need to return YES
to acknowledge that you've successfully opened the file.
If you have implemented this, is the message being sent?
Upvotes: 6