Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Build number and version in info.plist
ocgltd last edited by
I set VERSION=1.2.3 in my .pro file and I assume that gets pulled into the Info.plist file somewhere in the make process.
After uploading to Apple store, Apple reports my VERSION NUMBER as 1.2 and BUILD NUMBER as 1.2.3
I would like to replace BUILD NUMBER with an integer, ideally the same as ANDROID_VERSION_CODE also set in my .pro file. Can somone tell me if its possible to force a BUILD NUMBER into Info.plist which uses a variable from the .pro file?
Can somone tell me if its possible to force a BUILD NUMBER into Info.plist which uses a variable from the .pro file?
You can use QMAKE_SUBSTITUTES to generate a plist file with exact information you need. For example:
Info.plist.inwith the normal data you have in your plist, but replace version with a placeholder variable:
<key>CFBundleShortVersionString</key> <string>"$$LONG_VERSION"</string> <key>CFBundleVersion</key> <string>"$$BUILD_NUMBER"</string>
"need to be escaped:
\"in the input file, because
qmaketries to be clever ;-)
Then in .pro file you can do this:
LONG_VERSION="$$VERSION" BUILD_NUMBER="1234" plist.input = $$PWD/Info.plist.in plist.output = $$PWD/Info.plist QMAKE_SUBSTITUTES += plist QMAKE_INFO_PLIST = $$PWD/Info.plist
When you run qmake, it will generate
Info.plistfile with LONG_VERSION and BUILD_NUMBER replaced with what was specified in .pro.
I should add:
QMAKE_SUBSTITUTESis an undocumented feature of
qmake. It works reliably and since decades, it's used internally in Qt code a lot - but in theory it can stop working at any moment and without a warning.
@sierdzio good to know. thx. if there will be problems in future, it's easy to switch back and put version manually into info.plist.