My Mac app shows an error message when an associated file is double-clicked

59 views Asked by At

I'm developing a Mac app with Unity.
My app can import/export files, so I want to associate the file type with my app.
I edited the Info.plist like this:

<key>CFBundleDocumentTypes</key>
<array>
  <dict>
    <key>CFBundleTypeExtensions</key>
    <array>
      <string>XXX</string>
    </array>
    <key>CFBundleTypeIconFile</key>
    <string>FileIcon.icns</string>
    <key>CFBundleTypeName</key>
    <string>XXX File</string>
    <key>CFBundleTypeRole</key>
    <string>Viewer</string>
  </dict>
</array>

Then, my FileIcon.icns appears and my app is launched by double-clicking a XXX file.
But it shows a message such as

The document "sample.XXX" could not be opened. MyApp cannot open files in the "XXX File" format.

Some people say it can be handled by implementing application::openFile or application::openFiles in NSApplicationDelegate.

But I can't find how to implement them with Unity.

How can I handle this problem with Unity?

0

There are 0 answers