Search code examples
cordovaphonegap-buildphonegap

How to set different versions for Android and iOS apps in single config.xml (PhoneGap Build)?


My app uses 4-digits version numbers like this: "1.8.3.2". It's ok for Android, but App Store for iOS supports only 3-digits version numbers.

So, I need to set "1.8.3.2" for Android and "1.8.32" for iOS. How I can do this in single config.xml?


Solution

  • To achieve this, some post build editing of the generated manifest files is needed (AndroidManifest.xml and <app>-Info.plist for Android and iOS respectively).

    This can be automated with the cordova-custom-config plugin. First add the plugin:

    cordova plugin add cordova-custom-config
    

    Then add the following to your config.xml:

    <platform name="android">
        <preference name="android-manifest/@android:versionName" value="1.8.3.2" />
        ...
    </platform>
    ...
    <platform name="ios">
        <config-file parent="CFBundleShortVersionString" target="*-Info.plist" mode="replace"> 
            <string>1.8.32</string>
        </config-file>
        ...
    </platform>