Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

Using Cordova 3.5.0, when I run cordova prepare ios it overwrites my build number as well as the app's version number, using the version string from config.xml .

From:

<widget id="tld.domain.app" version="1.0.1"  

It sets the CFBundleVersion the same as the short version:

So I have to keep manually keep resetting my build number to my format which is YYYYMMDD.

Ideally I'd like it to either leave the build number alone, or be able to set it explicitly in the config.xml file.

Are either of these possible?

I found the answer in this resolved issue.

There are separate versionCode attributes (separate to version) for iOS and Android, that need to be added to your config.xml file:

<widget ... android-versionCode="201406092" ios-CFBundleVersion="201406092"
                A couple of weeks after this answer was posted, this information was added to the docs for the config.xml file ("Additional Versioning" section).
– TachyonVortex
                Mar 31, 2015 at 9:14
                Heads up, I noticed that in a new(er) cordova config.xml it's using version="1.23.456" and that number shows up for me on both Android & iOS builds.
– Jacksonkr
                Jun 9, 2020 at 22:29

This post here was a little clearer to me, a little more complete, so I mention it just in case it helps. Note that, effectively, it is almost the exact same as what Ade said. I only provide it because the first time I read Ade's answer, I was confused and did not fully understand his answer until I saw the answer below.

If you want to separate the build number from the version number, you can add the following attributes to the widget tag in your config.xml:

version="VERSIONNR" android-versionCode="BUILDNR" ios-CFBundleVersion="BUILDNR"
  

so the complete tag, with those attributes included, looks something like this:

<widget id="APPID" version="VERSIONNR" android-versionCode="BUILDNR" 
ios-CFBundleVersion="BUILDNR" xmlns="http://www.w3.org/ns/widgets"
xmlns:cdv="http://cordova.apache.org/ns/1.0">
  

(text in uppercase are placeholders)

Have to be careful with the android-versionCode attribute, I think it can't accept the same values as the ios-CFBundleVersion attribute. I had problems opening a cordova app in AndroidStudio when I set those attributes to the same value. Possibly android-versionCode has to be a whole number, while ios-CFBundleVersion can have decimal points? – newenglander Nov 5, 2015 at 14:09 Good point. In my case, the ios bundle has a decimal but the android does not. So ios has a build of 2.58, but android has a build of 258. I keep the two in sync so it is at least possible to tell the two devices use basically the same build. – Tony B Nov 6, 2015 at 17:50 version is with decimals, its what you call your version name "1.0.0" build number must be incremental integer, so ="1" eventually after some builds you notice that build number does not equal version name, they don't have to be a match, and they won't match eventually since build number is unique number that cannot repeat ( after being uploaded to the App store / google play console) – Miguel May 4, 2020 at 19:30

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.