Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make Finder 'Open With' work for my application (Xcode, OS X)?

I have created an application that is capable of playing audio files. This in itself works fine, and so does drag&drop from finder to my application.

What I would like as well, is that people can use my application from Finder using the Open With menu (or even allow them to set my application as default for a certain file type)

After a lot of searching, I found that I should configure a document type in Xcode (Editing information property lists) I successfully added such a type named 'Music File', with UTI 'public.mp3' When I now right-click an MP3 file, my application is listed in the 'Open With' menu. Trying to use it, my app opens, but I get a warning message saying "The document could not be opened. App cannot open files in the 'Music File' format"

It doesn't appear to be passed through the command line as is the case in Windows. My application does support drag&drop from Finder, and this is working fine too.

I don't really know where to look next, so it would be great if anyone could point me in the right direction. My application isn't using NSDocument, so the 'Class' field doesn't apply for me I think (and according to the docs this field isn't required, but it doesn't say how to handle it without a Class)

like image 739
Adion Avatar asked Jun 08 '10 14:06

Adion


People also ask

What is a Finder extension on Mac?

In OS X, the Finder Sync extension point lets you cleanly and safely modify the Finder's user interface to express file synchronization status and control. Unlike most extension points, Finder Sync does not add features to a host app. Instead, it lets you modify the behavior of the Finder itself.

How do I create an app using Xcode?

Launch Xcode, then click “Create a new Xcode project” in the Welcome to Xcode window or choose File > New > Project. In the sheet that appears, select the target operating system or platform and a template under Application.

How to add application to Open with list Mac?

Try selecting the file in the Finder and doing File > Get Info. From there you should be able to choose any application to open it with. Once you've opened that type of file in that application once, it should start appearing in the Open With menu.


1 Answers

Do you implement application:openFile: in your app delegate? This is the method that will be called when your application is asked to open a file from the Finder. If it's not implemented or doesn't return YES, then the framework will assume that the file wasn't opened successfully and report that fact to the user.

like image 111
Alex Avatar answered Sep 18 '22 01:09

Alex