1

在 Mac OS X 上,如果我的应用程序尚未运行,则通过双击文档打开我的文档会失败

通过双击文档启动我的绘图应用程序时,Finder 会显示一个对话框,其中显示:

无法打开文档“test.jdwg”。应用程序“jDraft”无法打开“jDraft 文档”格式的文件。

在此处输入图像描述

此消息对话框出现在我的应用程序甚至有时间放置其启动屏幕之前,但是应用程序在后台启动(我看到启动屏幕)并且当我再次双击文档时,我的应用程序正确打开它。

作为背景,这个应用程序已经(在这方面)工作了多年。当我尝试使用JWrapper打包我的应用程序时,现在出现了这个问题。

以下是Info.plist我的申请。

我怀疑这可能与 JWrapper 启动或派生 JVM 以运行应用程序的方式有关……很难说,因为 JWrapper 是封闭源代码,因此几乎超出了调试范围。

有没有人设法使文件关联在 Mac OS X 上与 JWrapper 一起工作?

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleName</key>
    <string>jDraft</string>
    <key>CFBundleIdentifier</key>
    <string>jwrapper.osx.jDraft</string>
    <key>CFBundleVersion</key>
    <string>43568712</string>
    <key>CFBundleAllowMixedLocalizations</key>
    <string>true</string>
    <key>CFBundleExecutable</key>
    <string>osxwrapper</string>
    <key>CFBundleDevelopmentRegion</key>
    <string>English</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>LSUIElement</key>
    <true/>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleIconFile</key>
    <string>AppLogo.icns</string>
    <key>NSHighResolutionCapable</key>
    <true/>
    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
    </dict>
    <key>CFBundleDocumentTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeName</key>
            <string>jDraft Drawing 2</string>
            <key>LSHandlerRank</key>
            <string>Default</string>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>CFBundleTypeIconFile</key>
            <string>jDraft-doc-jdwg.icns</string>
            <key>CFBundleTypeExtensions</key>
            <array>
                <string>jdwg</string>
            </array>
            <key>CFBundleTypeOSTypes</key>
            <array>
                <string>jdwg</string>
            </array>
        </dict>
    </array>
</dict>
</plist>
4

1 回答 1

1

我想我可以确认这是一个 JWrapper 问题,并且目前无法令人满意地解决。

我将 JWrapper 生成的捆绑包中的所有内容都复制到了没有此问题的原始应用捆绑包中(幸运的是,没有冲突的文件名!)。

我的应用程序仍然运行良好。

然后我在“Info.plist”中更改了这一属性

<key>CFBundleExecutable</key>
<string>JavaApplicationStub</string>

<key>CFBundleExecutable</key>
<string>osxwrapper</string>

问题又回来了,这意味着我在应用程序启动时得到了“无法打开”对话框。

所以我的结论是,这不是 Mac OS / Finder 正在执行此操作并发出对话框,而是 JWrapper osxwrapper发出了对话框并且无法将文档传递给我的 Java 代码或吞下“打开文档事件”。

我还尝试了osxlauncherJWrapper 放入.app/Contents/MacOS文件夹中的可执行文件——结果相同。

也许有一种方法可以告诉osxwrapper我我的应用程序可以打开这些文档,但我找不到任何文档。或者,这可能是一个不受支持的功能,这在其他出色的产品中将是一个严重的遗漏。

无论哪种方式,从 JWrapper 的人那里得到一个明确的答案都会很好,这样我就可以停止在这个问题上浪费我的时间了。

于 2016-05-05T05:21:54.950 回答