Setting native version numbers with capacitor?

With cordova, we could configure a few version numbers using attributes on the tag in config.xml:


How do we set those such that they make it over to the native project when capacitor is synced?

1 Like

Capacitor’s philosophy is to embrace the native project tooling and IDE’s instead of providing an abstracted config file like Cordova. As a general strategy, you’d search for “how to do X in Xcode?” or “… in Android Studio?”

For this question, setting Android version code, see here - most settings are configured in AndroidManifest.xml or the build.gradle.

For CGBundleVersion, it’s in Info.plist.

1 Like

Not a rant or anything … but the reason I choose Ionic was to NOT have to learn all the native features. Cordova and Ionic’s CLI on top was a great way to not have to dig into the mess of native IDEs.

I guess those days are numbered. :frowning:


You’ll get used to it quite quickly and actually there are a fair few advantages with this approach.

1 Like

Sorry but this solution doesn’t solve the problem. In my Ionic project there is no AndroidManifest.xml or build.gradle. Those files don’t exist until AFTER the Capacitor process generates the Android source. Your solution only works in a local build where you can modify that file. I’m using the Ionic cloud build and thus all the Android source is being generated on the server and I don’t have access to change that value. There MUST be some way to direct Capacitor to generate the correct value via an Ionic level configuration. I see that there is a capacitor.config.json file in the root of the Ionic project but I haven’t found any instructions on its usage.

To clarify, Appflow doesn’t generate your Capacitor-based Android project - it uses the one you previously committed to Git. Here’s the workflow:

  • Run npx cap add android locally. This generates an android folder in the root of your project.
  • Commit the android folder to source control.
  • Create a new native Android build in Appflow. Appflow builds the Android project.

It’s true that currently, Capacitor doesn’t have a version number property that you can sync over, like Cordova has in config.xml. So, you’d:

  • Make a code change.
  • Update the version number in AndroidManifest.xml.
  • Commit those changes to source control
  • Create a new native Android build in Appflow
  • and so forth…

Maybe we should update the docs and include capacitor in the build info: Package Builds | Ionic Documentation

It only mentions Cordova which discourages committing platform. Which gives the impression that it is generally disliked to commit platform builds.

1 Like