我可以将 Qt GUI 进程放在 Mac 包下的 Resources 文件夹中吗

Can I put a Qt GUI process in the Resources folder under a Mac bundle

有2个进程。一个是位于 MacOS 文件夹下 Mac 包下的 GUI 进程,而另一个是托盘进程,位于包下的 Resources 文件夹中。托盘进程似乎无法找到 cocoa plugin/library。因为我手动运行的时候,出现如下错误

This application failed to start because it could not find or load the Qt platform plugin "cocoa" in "".

包结构如下所示

-Contents
 |_MacOS
 | |_gui
 |
 |_Resources
 | |_tray
 | |_qt.conf
 |
 |_Plugins
   |_platforms
     |_libqcocoa.dylib

qt.conf 包含

[Paths]
Plugins = PlugIns
Imports = Resources/qml
Qml2Imports = Resources/qml

将托盘进程放入 Mac 包内的资源文件夹中是正确的做法吗?

根据 Bundle Programming GuideResources 文件夹用于存储图像、声音等资源(参见 Table 2-5):

Contains all of the application’s resource files. This contents of this directory are further organized to distinguish between localized and nonlocalized resources. For more information about the structure of this directory, see The Resources Directory.

和:

The Resources directory is where you put all of your images, sounds, nib files, string resources, icon files, data files, and configuration files among others

但是 MacOS 文件夹也可能包含辅助可执行文件:

Contains the application’s standalone executable code. Typically, this directory contains only one binary file with your application’s main entry point and statically linked code. However, you may put other standalone executables (such as command-line tools) in this directory as well.

因此,我认为 MacOS 文件夹是 tray 二进制文件的最佳位置。不知道是否解决了平台插件缺失的问题