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 10.3k 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.
  • M Offline
    M Offline
    Mr .Wu
    wrote on last edited by
    #1

    I want set and get the version of the application in ***.pro

    1 Reply Last reply
    0
    • EddyE Offline
      EddyE Offline
      Eddy
      wrote on last edited by
      #2

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

      A simple solution can be this one

      Eddy

      Qt Certified Specialist
      www.edalsolutions.be

      ekkescornerE M C 3 Replies Last reply
      3
      • EddyE Eddy

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

        A simple solution can be this one

        Eddy

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

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

        A simple solution can be this one

        that is a simple and great solution
        but I didn't found a way HowTo use this APP_VERSION automagically also inside Android Manifest file and iOS info.plist - perhaps I did it the wrong way

        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
        • EddyE Eddy

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

          A simple solution can be this one

          Eddy

          M Offline
          M Offline
          Mr .Wu
          wrote on last edited by
          #4

          @Eddy Thanks . That's what I want

          1 Reply Last reply
          1
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Hi,

            @ekkescorner IIRC I did something "automagical" using a sed command for Android and PlistBuddy for iOS.

            I added a QMAKE_EXTRA_TARGETS for each platform and also added the command to PRE_TARGETDEPS

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

            ekkescornerE 1 Reply Last reply
            1
            • SGaistS SGaist

              Hi,

              @ekkescorner IIRC I did something "automagical" using a sed command for Android and PlistBuddy for iOS.

              I added a QMAKE_EXTRA_TARGETS for each platform and also added the command to PRE_TARGETDEPS

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

              @SGaist sounds good, but I don't really understand ;-)
              do you have an example how it looks in your .pro and in android manifest and ios plist ?
              thx

              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
              1
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on 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

                ekkescornerE 2 Replies Last reply
                3
                • SGaistS SGaist

                  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
                  }
                  
                  ekkescornerE Offline
                  ekkescornerE Offline
                  ekkescorner
                  Qt Champions 2016
                  wrote on 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.9 https://t1p.de/ekkeChecklist
                  QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

                  1 Reply Last reply
                  2
                  • SGaistS SGaist

                    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
                    }
                    
                    ekkescornerE Offline
                    ekkescornerE Offline
                    ekkescorner
                    Qt Champions 2016
                    wrote on 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.9 https://t1p.de/ekkeChecklist
                    QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 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

                      ekkescornerE 1 Reply Last reply
                      2
                      • SGaistS SGaist

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

                        ekkescornerE Offline
                        ekkescornerE Offline
                        ekkescorner
                        Qt Champions 2016
                        wrote on 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.9 https://t1p.de/ekkeChecklist
                        QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on 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

                          ekkescornerE 1 Reply Last reply
                          1
                          • SGaistS SGaist

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

                            ekkescornerE Offline
                            ekkescornerE Offline
                            ekkescorner
                            Qt Champions 2016
                            wrote on 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.9 https://t1p.de/ekkeChecklist
                            QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

                            1 Reply Last reply
                            0
                            • SGaistS Offline
                              SGaistS Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on 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

                              ekkescornerE 1 Reply Last reply
                              0
                              • SGaistS SGaist

                                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 :)

                                ekkescornerE Offline
                                ekkescornerE Offline
                                ekkescorner
                                Qt Champions 2016
                                wrote on 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.9 https://t1p.de/ekkeChecklist
                                QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

                                1 Reply Last reply
                                0
                                • EddyE Eddy

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