我看到很多关于此问题的问题和帖子,几乎在所有地方我都看到被op
要求参考http://doc.qt.io/qt-5/osx-deployment.html
但对于刚接触Qt的人来说,问题是很难理解如何生成dmg文件。
我们不要深入讨论项目中的外部库、插件等。
如果我们创建一个全新的QWidget程序,没有一行代码,默认的项目只是显示一个窗口,那么怎么会有人生成dmg文件呢。
如果我们在文件夹macdeployqt yourProjectName.app -dmg
内执行debug build
此操作,而不执行任何操作,那么它当然会创建 dmg 文件,但无法打开,现在如果您尝试运行默认项目,则会面临以下错误:
This application failed to start because it could not find or load
the Qt platform plugin "cocoa"
in "".
Available platform plugins are: cocoa.
Reinstalling the application may fix this problem.
The program has unexpectedly finished.
Run Code Online (Sandbox Code Playgroud)
那么,为Qt应用程序生成dmg文件的过程是怎样的呢?
编辑:详细讨论在这里: https: //forum.qt.io/topic/82746/creating-dmg-for-qt-app-mac-osx