将 Qt 添加到 Xcode 项目?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/668604/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Adding Qt to Xcode project?
提问by bias
I have a fairly complex Xcode project and I want to add Qt to it. I know that I can create a newproject using qmake -spec macx-xcode project.pro
but I don't want to have to hand configure my old project over the auto generated Qt project. Is there another option?
我有一个相当复杂的 Xcode 项目,我想向其中添加 Qt。我知道我可以使用创建一个新项目,qmake -spec macx-xcode project.pro
但我不想通过自动生成的 Qt 项目手动配置我的旧项目。还有其他选择吗?
[edited in a more general question below]
[在下面更一般的问题中编辑]
It seems like it would be easier to simply use qmake as my build system. Hence, adding my old project build process to the .profile and use that to generate a new .xcodeproj? I would only do this if I could comprehensively configure the .pro file so that I don't have to hand configure the .xcodeproj- is this doable? I really don't want to have to mess around with hand configuring the .xcodeprojeach time I run qmake.
似乎简单地使用 qmake 作为我的构建系统会更容易。因此,将我的旧项目构建过程添加到.pro文件并使用它来生成新的.xcodeproj?如果我可以全面配置 .pro 文件,那么我只会这样做,这样我就不必手动配置.xcodeproj- 这可行吗?我真的不想在每次运行 qmake 时都手动配置.xcodeproj。
Essentially, is qmake (or a meta-build in general) a valid substitute for a normal build system, such that I don't need to tweak the resulting build system generated by qmake?
从本质上讲,qmake(或一般的元构建)是否是正常构建系统的有效替代品,这样我就不需要调整由 qmake 生成的构建系统?
Are there better resources besides the manualand tutorialprovided by Trolltech? I'm concerned that wikipediasays that qmake is primarily for internal use and not well documented.
回答by dirkgently
Build an empty xcode project with qmake and incorporate the compiler settings to your existing project from the generated Makefile. Of course, you will have to set up your existing project to run qmake as a pre-build step if you are using Qt-specific extensions.
使用 qmake 构建一个空的 xcode 项目,并将编译器设置从生成的 Makefile 合并到您现有的项目中。当然,如果您使用 Qt 特定的扩展,您将必须设置现有项目以运行 qmake 作为预构建步骤。
What do you think is the easiest method for integrating established projects with Qt?
您认为将已建立的项目与 Qt 集成的最简单方法是什么?
That depends on the nature of your work. I wish I could have given a more specific answer here but I really can't. Also, are you using Qt professional? In that case, you can get support (at least that's how it was, during 3.3 when I last worked on it for anything production-quality). If all you care about Qt is the graphics part, I'd say don't bother changing your build system, rather see to it that you get the code to compile and link and run just fine. But, if you are going to use signals and slots and what not -- think about moving over.
这取决于你的工作性质。我希望我能在这里给出更具体的答案,但我真的不能。另外,您使用的是Qt专业版吗?在这种情况下,您可以获得支持(至少在 3.3 期间我上次为任何生产质量工作时是这样)。如果你只关心 Qt 的图形部分,我会说不要费心改变你的构建系统,而是确保你得到代码来编译和链接并运行得很好。但是,如果您打算使用信号和插槽,而其他不使用 - 考虑移动。
Would you recommend I do the xcodeproj merge I asked about and which you answered, or should I start from scratch with qmake like I edited a question about?
你会建议我做我问过的 xcodeproj 合并,你回答了什么,还是应该像我编辑了一个问题一样从头开始使用 qmake?
Again, look at the size of your project. Assuming a fairly complex project, I'd hazard a guess that you have about 2/3 man-days worth of effort to rewrite the build system? Is this project a serious one, something that will be maintained over a period of time? Is this cross-platform? Will you be using Qt throughout?
再次,看看你的项目的大小。假设一个相当复杂的项目,我敢猜测您有大约 2/3 人日的努力来重写构建系统?这个项目是一个严肃的项目,会在一段时间内维护吗?这是跨平台的吗?你会一直使用 Qt 吗?
If there is an overbearing reason to feel that Qt is the way forward I'd suggest that you start using their build system.
如果有一个霸道的理由认为 Qt 是前进的方向,我建议您开始使用他们的构建系统。
回答by aurelius
One of the main points of using Qt is the portability of the Gui. It only makes sense to extend this feature to your build process by using qmake and allowing users/developers generate whichever build system they want to use (make, visualstudio, xcode).
使用 Qt 的要点之一是 Gui 的可移植性。通过使用 qmake 并允许用户/开发人员生成他们想要使用的任何构建系统(make、visualstudio、xcode),将此功能扩展到您的构建过程才有意义。
No, qmake is not well documented and more poignantly there are not manifold examples like there are for make. But, it is similar to make and should be intuitive. Why not absorb the overhead to learn it and pass the benefit on to your users/developers?
不,qmake 没有很好的文档记录,更令人痛心的是,没有像 make 那样的多种示例。但是,它类似于 make 并且应该是直观的。为什么不吸收开销来学习它并将好处传递给您的用户/开发人员?
回答by Patrick Stinson
It's really, really, really nice to have a single IDE and debugger that works on all the platforms you are writing for, but I have found that it's also pretty nice to just use the native tools.
拥有一个可以在您编写的所有平台上运行的单一 IDE 和调试器真的非常非常好,但我发现仅使用本机工具也非常好。
Once you put in the time to learn each build system, it's pretty easy to maintain the projects to a very precise degree.
一旦您花时间学习每个构建系统,就很容易将项目维护到非常精确的程度。