Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Build number and version in info.plist

Build number and version in info.plist

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
5 Posts 3 Posters 2.6k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ocgltdO Offline
    ocgltdO Offline
    ocgltd
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

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

      (Z(:^

      ekkescornerE 1 Reply Last reply
      1
      • sierdzioS sierdzio

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

        ekkescornerE Offline
        ekkescornerE Offline
        ekkescorner
        Qt Champions 2016
        wrote on last edited by
        #3

        @sierdzio cool.

        ekke ... Qt Champion 2016 | 2024 ... mobile business apps
        5.15 --> 6.9 https://t1p.de/ekkeChecklist
        QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          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.

          (Z(:^

          ekkescornerE 1 Reply Last reply
          0
          • sierdzioS sierdzio

            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.

            ekkescornerE Offline
            ekkescornerE Offline
            ekkescorner
            Qt Champions 2016
            wrote on last edited by
            #5

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

            ekke ... Qt Champion 2016 | 2024 ... mobile business apps
            5.15 --> 6.9 https://t1p.de/ekkeChecklist
            QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved