Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How can i set and get the application version

How can i set and get the application version

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
16 Posts 5 Posters 9.2k Views
  • 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.
  • S Offline
    S Offline
    SGaist
    Lifetime Qt Champion
    wrote on 20 Jun 2017, 06:48 last edited by
    #7

    WARNING *nix style OS required:

    Something along the line:

    VERSION = 1.2.3
    
    android {
        androidmanifestupdate.commands =  sed -i \'\' -E -e \'s/(versionName=)(\"([0-9]\.?)+\")/\\1\"$$VERSION\"/g\' $$ANDROID_PACKAGE_SOURCE_DIR/AndroidManifest.xml
        QMAKE_EXTRA_TARGETS += androidmanifestupdate
        PRE_TARGETDEPS += androidmanifestupdate
    }
    
    ios {
        plistupdate.commands = /usr/libexec/PlistBuddy -c \"Set :CFBundleShortVersionString $$VERSION\" $$QMAKE_INFO_PLIST
        QMAKE_EXTRA_TARGETS += plistupdate
        PRE_TARGETDEPS += plistupdate
    }
    

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    E 2 Replies Last reply 20 Jun 2017, 06:56
    3
    • S SGaist
      20 Jun 2017, 06:48

      WARNING *nix style OS required:

      Something along the line:

      VERSION = 1.2.3
      
      android {
          androidmanifestupdate.commands =  sed -i \'\' -E -e \'s/(versionName=)(\"([0-9]\.?)+\")/\\1\"$$VERSION\"/g\' $$ANDROID_PACKAGE_SOURCE_DIR/AndroidManifest.xml
          QMAKE_EXTRA_TARGETS += androidmanifestupdate
          PRE_TARGETDEPS += androidmanifestupdate
      }
      
      ios {
          plistupdate.commands = /usr/libexec/PlistBuddy -c \"Set :CFBundleShortVersionString $$VERSION\" $$QMAKE_INFO_PLIST
          QMAKE_EXTRA_TARGETS += plistupdate
          PRE_TARGETDEPS += plistupdate
      }
      
      E Offline
      E Offline
      ekkescorner
      Qt Champions 2016
      wrote on 20 Jun 2017, 06:56 last edited by
      #8

      @SGaist cool :)

      never would have found out this ...

      to also set CFBundleVersion do I need a second plistupdate.commands line or can I combine it to set CFBundleVersion to same value as CFBundleShortVersion

      thx again
      if it comes to such kind of stuff I always need help being only an experienced business app developer relying on IDEs ;-)

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

      1 Reply Last reply
      2
      • S SGaist
        20 Jun 2017, 06:48

        WARNING *nix style OS required:

        Something along the line:

        VERSION = 1.2.3
        
        android {
            androidmanifestupdate.commands =  sed -i \'\' -E -e \'s/(versionName=)(\"([0-9]\.?)+\")/\\1\"$$VERSION\"/g\' $$ANDROID_PACKAGE_SOURCE_DIR/AndroidManifest.xml
            QMAKE_EXTRA_TARGETS += androidmanifestupdate
            PRE_TARGETDEPS += androidmanifestupdate
        }
        
        ios {
            plistupdate.commands = /usr/libexec/PlistBuddy -c \"Set :CFBundleShortVersionString $$VERSION\" $$QMAKE_INFO_PLIST
            QMAKE_EXTRA_TARGETS += plistupdate
            PRE_TARGETDEPS += plistupdate
        }
        
        E Offline
        E Offline
        ekkescorner
        Qt Champions 2016
        wrote on 20 Jun 2017, 06:57 last edited by
        #9

        @SGaist said in How can i set and get the application version:

        WARNING *nix style OS required:

        doing all my work on macOS so it should work :)

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

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 20 Jun 2017, 09:11 last edited by SGaist
          #10

          You can add several -c parameter to PlistBuddy and the same for the -e parameter for sed.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          E 1 Reply Last reply 20 Jun 2017, 09:14
          2
          • S SGaist
            20 Jun 2017, 09:11

            You can add several -c parameter to PlistBuddy and the same for the -e parameter for sed.

            E Offline
            E Offline
            ekkescorner
            Qt Champions 2016
            wrote on 20 Jun 2017, 09:14 last edited by
            #11

            @SGaist would this be ok ?

            plistupdate.commands = /usr/libexec/PlistBuddy -c \"Set :CFBundleShortVersionString $$VERSION\", \"Set :CFBundleVersionString $$VERSION\" $$QMAKE_INFO_PLIST
            

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

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 20 Jun 2017, 09:32 last edited by
              #12

              IIRC, no. What I meant is: -c "something" -c "some other thing"

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              E 1 Reply Last reply 20 Jun 2017, 09:35
              1
              • S SGaist
                20 Jun 2017, 09:32

                IIRC, no. What I meant is: -c "something" -c "some other thing"

                E Offline
                E Offline
                ekkescorner
                Qt Champions 2016
                wrote on 20 Jun 2017, 09:35 last edited by
                #13

                @SGaist thx again
                you see - I'm really not experienced in this area ;-)

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

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 20 Jun 2017, 09:55 last edited by
                  #14

                  Use the terminal ekke ;-)

                  More seriously, that one can be tricky. Some tools allows several arguments for an option while other like this one allows to re-use an option several times and for some you just can't and you have to call the command itself several times. All in all, you first have to play with them a bit and then you can start doing things :)

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  E 1 Reply Last reply 20 Jun 2017, 10:09
                  0
                  • S SGaist
                    20 Jun 2017, 09:55

                    Use the terminal ekke ;-)

                    More seriously, that one can be tricky. Some tools allows several arguments for an option while other like this one allows to re-use an option several times and for some you just can't and you have to call the command itself several times. All in all, you first have to play with them a bit and then you can start doing things :)

                    E Offline
                    E Offline
                    ekkescorner
                    Qt Champions 2016
                    wrote on 20 Jun 2017, 10:09 last edited by
                    #15

                    @SGaist said in How can i set and get the application version:

                    Use the terminal ekke ;-)

                    only if there's no other way

                    More seriously, that one can be tricky. Some tools allows several arguments for an option while other like this one allows to re-use an option several times and for some you just can't and you have to call the command itself several times. All in all, you first have to play with them a bit and then you can start doing things :)

                    I know why I don't like this kind of stuff.
                    Will ask the experts if I need help and go on to develop cool mobile business apps and evangelize Qt-for-mobile at developer conferences :)

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

                    1 Reply Last reply
                    0
                    • EddyE Eddy
                      15 Jun 2017, 12:56

                      @Mr-Wu
                      There are numerous solutions for you if you google.

                      A simple solution can be this one

                      Eddy

                      C Offline
                      C Offline
                      chrisjbird
                      wrote on 5 Nov 2019, 20:14 last edited by
                      #16

                      @Eddy I found this thread via Google.

                      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