Search code examples
cordovaphonegap-buildcordova-3cordova-plugins

Per platform configuration (config.xml) on cordova


something like-

<gap:config-file platform="ios" parent="UISupportedInterfaceOrientations" overwrite="true">
   <array>
      <string>UIInterfaceOrientationPortrait</string>
   </array>
</gap:config-file>

like the answer from this question regarding Phonegap.

is there an option for it in config.xml on Cordova?


Solution

  • For screen orientation, adding <preference name="Orientation" value="portrait" /> will result in the CLI adding the specific tags in the platform specific config files each time you build (androidmanifest.xml for android and sorry I don't know much about IOS...)

    If you want to force the orientation for ios but not android, you can try this :

    <platform name="ios">
            <preference name="Orientation" value="portrait" />
    </platform>
    

    For other options, there are tags that are recognised only by some platforms so you add them to config.xml and the cli uses it or not depending on the platform. See here fore android-only options and here for ios-only options.

    For things like plugins, you use the cli to customize each platform, but don't touch config.xml.

    For other things unfortunatly you may have to manually edit the specific platform config file (ie androidmanifest.xml) once the platform has been added to the project. When you build the project, those options should be kept in the config file.