如何将资源、框架或插件复制/更新到 (Mac OS X)“应用程序包”使用 Qt Creator 或 qmake
我已经阅读了几天有关如何使用 Qt Creator 或 qmake 将外部资源、插件或框架复制/更新到我的应用程序的 Mac Bundle 的内容。
现在我找到了两个主要的解决方案。一种是在“.pro”文件上结合使用 qmake 和一些命令。另一种是执行“自定义部署步骤”脚本。
我希望使用第二个选项,因为我已经有一个小的 make 脚本可以完成我想要的操作。问题是 Qt Creator 提供的变量太少,导致脚本失去了用处。例如,我的脚本使用“目标应用程序路径”作为参数,因此它可以从那里完成所有工作。但如果我错了,请纠正我,Qt Creator 只提供 %{buildDir} 和 %{sourceDir} 变量...
另一个选项是使用 qmake。这些是我迄今为止在“.pro”文件上尝试过的操作:
1)使用INSTALL命令。我做了一个小测试,尝试以这种方式复制一些文件:
MediaFiles.path = test/media
MediaFiles.files = media/*
INSTALL += MediaFiles
基本上什么也没发生。我希望在“测试”文件夹中找到相同的“媒体”文件夹,但什么也没有。不知道我是否做错了什么。
请注意,“media”文件夹位于“test”文件夹和“.pro”文件旁边。 (它们都具有相同的层次结构位置。)
2)然后我尝试了QMAKE_BUNDLE_DATA:
MediaFiles.path = Contents/MacOS
MediaFiles.files = media/*
QMAKE_BUNDLE_DATA += MediaFiles
但这给了我以下错误:
usage: cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file target_file
cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file ... target_directory
make: *** [PathToApp] Error 64
到目前为止,没有一个解决方案似乎令人满意。如果我想做一个好的自定义脚本,我需要分别对每个目标路径进行硬编码。就我而言,我有 8 个不同的目标路径,具体取决于一些“CONFIG”变量。
我确信 qmake 解决方案是执行此操作的官方方法。如果有人能指出错误 64 的解决方案那就太好了。
还有一些问题: 每次我想要更新我的包时都必须执行 qmake 吗? 我可以使用 qmake 执行 make 脚本吗?
I've been reading for a couple days on how to copy/update external resources, plugins or frameworks to my App's Mac Bundle using Qt creator or qmake.
Right now I have found two main solutions. One is to use qmake together with some commands on the ".pro" file. The other one is to do a "Custom Deployment Step" script.
I was hoping to use the second option cause I already had a small make script that did what I wanted. The problem is that Qt Creator offers so little variables to work with that the script lost its usefulness. For instance, my script uses the "Target App Path" as a parameter so it can do all its work from there. But please correct me if I'm wrong, Qt Creator only offers %{buildDir} and %{sourceDir} variables...
The other option is using qmake. These are the things that I have tried so far on my ".pro" file:
1) Using the INSTALL command. I did a small test where I tried copying some files this way:
MediaFiles.path = test/media
MediaFiles.files = media/*
INSTALL += MediaFiles
And basically nothing happend. I was hopping to find the same "media" folder on the "test" folder but nothing. Don't know if I'm doing something wrong.
Please note that the "media" folder is beside the "test" folder and the ".pro" file. (They all have the same hierarchy position.)
2) Then I tried QMAKE_BUNDLE_DATA:
MediaFiles.path = Contents/MacOS
MediaFiles.files = media/*
QMAKE_BUNDLE_DATA += MediaFiles
But this gave me the following error:
usage: cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file target_file
cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file ... target_directory
make: *** [PathToApp] Error 64
None of the solutions seem to be pleasing so far. If I wanted to do a good custom make script I will need to hardcode every target path separately. In my case I have 8 different target path depending on some "CONFIG" variables.
I'm sure the qmake solution are the official way of doing this. If someone can point me out the solution to the Error 64 would be cool.
Some further question:
Do I have to do a qmake every time I want to update my bundle?
Can I execute my make script with the qmake?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将命令放在 .pro 脚本末尾后,QMAKE_BUNDLE_DATA 开始完美工作。
QMAKE_BUNDLE_DATA started working flawlessly after putting the command on the end of the .pro script.