[QMAKE/CMAKE] Build apk and ios App via terminal
-
Hi ,
i know there's a qt creator that can build apk and ios app easily , but there are times that i have no access on the company mac machine , and the only way to connect to the mac is via ssh , our company doesn't allow us to connect to mac via vnc /remoteso the only way i think is to build apk / ios app via terminal .
in normal android app and normal ios app , i can easily done this using the gradle command for android and the xcodebuild command for ios, but for the qmake i have no idea how can i build both apps via terminal .thanks in advance for the help :)
if possible please post both cmake command and qmake command :) thank you very much.
-
When you build in Qt Creator, see the first line in "Compile Output" tab - it contains full command line used to run
qmake. Once qmake is done, you just need to follow it withmake -j Xwhere X is the number of cores in your cpu.You may need to follow that with a call to
androiddeployqtlater. -
When you build in Qt Creator, see the first line in "Compile Output" tab - it contains full command line used to run
qmake. Once qmake is done, you just need to follow it withmake -j Xwhere X is the number of cores in your cpu.You may need to follow that with a call to
androiddeployqtlater.@sierdzio said in [QMAKE] Build apk and ios App via terminal:
When you build in Qt Creator, see the first line in "Compile Output" tab - it contains full command line used to run
qmake. Once qmake is done, you just need to follow it withmake -j Xwhere X is the number of cores in your cpu.You may need to follow that with a call to
androiddeployqtlater.noted thanks ,
what is counterpart of "androiddeployqt" on ios ? iosdeployqt?also , if i use the cmake . is it the same ? thanks
-
@sierdzio said in [QMAKE] Build apk and ios App via terminal:
When you build in Qt Creator, see the first line in "Compile Output" tab - it contains full command line used to run
qmake. Once qmake is done, you just need to follow it withmake -j Xwhere X is the number of cores in your cpu.You may need to follow that with a call to
androiddeployqtlater.noted thanks ,
what is counterpart of "androiddeployqt" on ios ? iosdeployqt?also , if i use the cmake . is it the same ? thanks
@jhayar said in [QMAKE/CMAKE] Build apk and ios App via terminal:
what is counterpart of "androiddeployqt" on ios ? iosdeployqt?
I think there is no counterpart, xcode already builds the whole package. But it's been a few years since I worked on any iOS app, maybe I don't remember well.
also , if i use the cmake . is it the same ? thanks
In a nutshell yes. But I think there are some helper methods that will run deployment automatically for you. You'll need to search, Qt company has put up a few blog posts about cmake, Android and Qt.
-
I cannot speak to the CMake part of the question. I have never used Cmake with iOS apps.
But for
qmakeand iOS, it is possible to build in a terminal.However, after building, I normally still open XCode manually ("point and click") in order to either submit the app to the Apple Store or to deploy to a locally-connected device. There are probably (??) additional exclusively-command-line ways to achieve those subsequent tasks, but I do not know them.
Compiling for iOS is definitely possible, though. I do it in CI (continuous integration) to make sure no commits made from other platforms "break the build" for iOS.
In what is a typical pattern for
qmake, the main "trick" is just to make sure you invoke the iOS-specific qmake.So instead of invoking:
- Qt_desktop/5.15.0/clang_64/bin/qmake # <<--- this would NOT produce an iOS app.
You make sure to invoke:
Qt_desktop/5.15.0/ios/bin/qmake
If you manage to run the correct
qmake, then from there, the Qt/qmake build infrastructure should successfully drive XCode to run a build with iOS specific options, things that look like:-target x86_64-apple-ios12.0-simulator-isysroot .../iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.7.sdk
Instead of the MacOS desktop options:
-mmacosx-version-min=10.13-isysroot ...MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk
To be clear: those last bullet points all show options passed to
clang, but you do not have to manually deal with any of that. All you should need to worry about is locating the correctqmakebinary. If you start with the rightqmake, the rest should fall into place automatically.Here is the script that I use in CI:
(as of Nov 2022) It is working! I just ran a CI build this morning to make sure (before posting this).
You might also find it useful to look at the commit when our iOS build script was added to CI: