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



  • 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?


  • Moderators

    @ocgltd said in Build number and version in info.plist:

    Can somone tell me if its possible to force a BUILD NUMBER into Info.plist which uses a variable from the .pro file?

    Not directly.

    You can use QMAKE_SUBSTITUTES to generate a plist file with exact information you need. For example:

    Create Info.plist.in with 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>
    
    

    All quotes " need to be escaped: \" in the input file, because qmake tries 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.plist file with LONG_VERSION and BUILD_NUMBER replaced with what was specified in .pro.


  • Qt Champions 2016

    @sierdzio cool.


  • Moderators

    I should add: QMAKE_SUBSTITUTES is 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.


  • Qt Champions 2016

    @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.


Log in to reply