How can i set and get the application version
-
@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 -
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 toPRE_TARGETDEPS
-
@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 -
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 }
-
@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 ;-) -
@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 :)
-
You can add several
-c
parameter to PlistBuddy and the same for the-e
parameter for sed. -
@SGaist would this be ok ?
plistupdate.commands = /usr/libexec/PlistBuddy -c \"Set :CFBundleShortVersionString $$VERSION\", \"Set :CFBundleVersionString $$VERSION\" $$QMAKE_INFO_PLIST
-
IIRC, no. What I meant is:
-c "something" -c "some other thing"
-
@SGaist thx again
you see - I'm really not experienced in this area ;-) -
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 :)
-
@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 :)