[英]How can I build an ios executable using Qt 5.2 and qmake from the commandline?
I have been using Qt on desktop platforms for years (since Qt3). 多年来我一直在桌面平台上使用Qt(从Qt3开始)。 Having been doing quite a bit of mimimal QtQuick/QML stuff recently, I'm interested to try out Qt5.2's newfangled ios support (which would be my first venture into anything "mobile").
我最近做了相当多的最小QtQuick / QML的东西,我有兴趣尝试Qt5.2的新奇ios支持(这将是我第一次冒险进入任何“移动”)。 I'm having trouble figuring out how to build anything but the usual MacOS apps though.
我很难弄清楚除了通常的MacOS应用程序之外如何构建任何东西。
I have: 我有:
For starters, I'll settle for something really simple; 首先,我会满足于一些非常简单的事情; this
test.pro
: 这个
test.pro
:
TEMPLATE = app
TARGET = test
CONFIG += debug
QT += core gui quick
SOURCES += main.cpp
and main.cpp
: 和
main.cpp
:
#include <iostream>
#include <QGuiApplication>
#include <QQuickView>
int main(int argc,char *argv[])
{
QGuiApplication app(argc,argv);
QQuickView view;
view.setSource(QUrl::fromLocalFile("test.qml"));
view.show();
return app.exec();
}
(of course there's also a test.qml
but it's irrelevant here) and then I try and build it with (当然还有一个
test.qml
但它在这里无关紧要)然后我尝试用它构建它
qmake -spec macx-xcode test.pro
which gets me a test.xcodeproj/
created, and then 它让我得到一个
test.xcodeproj/
created,然后
xcodebuild -project test.xcodeproj -alltargets
builds a bunch of stuff... but just yields a MacOS app, albeit one which runs as expected on the Mac with ./Debug/test.app/Contents/MacOS/test
. 构建了一堆东西......但只是产生了一个MacOS应用程序,尽管它在Mac上运行时带有
./Debug/test.app/Contents/MacOS/test
。
The qmake
used is definitely the one from the "Qt 5.2.1 for iOS" install. 使用的
qmake
绝对是“Qt 5.2.1 for iOS”安装中的一个。
So, what do I do to change in the above to get ios executable I can run with xcode's ios simulator (including, ideally, launching the simulator from the commandline) ? 那么, 我该如何改变以上来获得ios可执行文件我可以使用xcode的ios模拟器运行 (包括理想情况下, 从命令行启动模拟器) ?
Haven't had much luck googling for solutions; 没有太多的运气谷歌搜索解决方案; everything I've found seems to just say "and then you open the xcodeproj file in xcode and build it".
我发现的一切似乎只是说“然后你在xcode中打开xcodeproj文件并构建它”。 I've tried that and (once I figured out the project needed to be added to a workspace) it just builds me a MacOS app too, which leads me to suspect the qmake needs to be doing something, but if it was as simple as a different
-spec
argument I'd have thought I'd have discovered that. 我已经尝试过了(一旦我弄清楚需要将项目添加到工作区),它只是构建了一个MacOS应用程序,这让我怀疑qmake需要做什么,但如果它就像它一样简单一个不同的
-spec
参数我以为我已经发现了。 (BTW, I've never used xcode before and would rather interact with whatever it brings to ios building via commandline & scripting if at all possible). (顺便说一下,我之前从未使用过xcode,而且如果可能的话,我宁愿通过命令行和脚本与ios构建的内容进行交互)。
The fix turns out to be simple: 修复结果很简单:
Use the 5.2.1/ios/bin/qmake
instead of the 5.2.1/clang_64/bin/qmake
one. 使用
5.2.1/ios/bin/qmake
而不是5.2.1/clang_64/bin/qmake
。
I was enlightened regarding this important detail via the Qt Forum . 通过Qt论坛,我对这一重要细节有了启发。
Haven't discovered how to do a complete commandline workflow to the iOS simulator yet, but launching it from xcode is simple enough. 尚未发现如何为iOS模拟器完成一个完整的命令行工作流,但是从xcode启动它很简单。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.