Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-12381

Cordova's prepare command does not work reliably when it comes to restoring the platforms & plugins via config.xml

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 6.4.0
    • None
    • cordova-cli, cordova-ios
    • macOS Sierra 10.12.2, current versions of cordova and cordova-ios

    Description

      Howdy,

      I just figured out, that the cordova prepare command does not work reliably when it restores everything from the config.xml.

      Steps to reproduce

      1. Install cordova via npm install cordova into an empty folder
      2. Run $(npm bin)/cordova create sampleProject to create a new cordova project
      3. Open the folder sampleProject
      4. Run $(npm bin)/cordova platform add ios --save to add ios
      5. Run $(npm bin)/cordova plugin add cordova-plugin-statusbar --save to add the status bar plugin
      6. Open the config.xml and add this before the last closing tag: <preference name="StatusBarOverlaysWebView" value="false"/>
      7. Remove the folders platform and plugins. Now you have a project, which you normally check in into your source control system, since cordova is able to restore everything from config.xml
      8. Run $(npm bin)/cordova prepare to restore
      9. Open platforms/ios/HelloCordova.xcodeproj in XCode
      10. Start it (simulator is ok)
      11. Notice, that the status bar does overlay the WebView
      12. Run $(npm bin)/cordova prepare again
      13. Start the project in XCode again
      14. Notice, that the status bar does not overlay the WebView

      What happened?

      In step 8 the file platforms/ios/HelloCordova/config.xml was created by cordova looking like that:

      <?xml version='1.0' encoding='utf-8'?>
      <widget id="io.cordova.hellocordova" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
          <feature name="LocalStorage">
              <param name="ios-package" value="CDVLocalStorage" />
          </feature>
          <feature name="HandleOpenUrl">
              <param name="ios-package" value="CDVHandleOpenURL" />
              <param name="onload" value="true" />
          </feature>
          <feature name="IntentAndNavigationFilter">
              <param name="ios-package" value="CDVIntentAndNavigationFilter" />
              <param name="onload" value="true" />
          </feature>
          <feature name="GestureHandler">
              <param name="ios-package" value="CDVGestureHandler" />
              <param name="onload" value="true" />
          </feature>
          <name>HelloCordova</name>
          <description>
              A sample Apache Cordova application that responds to the deviceready event.
          </description>
          <author email="dev@cordova.apache.org" href="http://cordova.io">
              Apache Cordova Team
          </author>
          <content src="index.html" />
          <access origin="*" />
          <allow-intent href="http://*/*" />
          <allow-intent href="https://*/*" />
          <allow-intent href="tel:*" />
          <allow-intent href="sms:*" />
          <allow-intent href="mailto:*" />
          <allow-intent href="geo:*" />
          <allow-intent href="itms:*" />
          <allow-intent href="itms-apps:*" />
          <preference name="AllowInlineMediaPlayback" value="false" />
          <preference name="BackupWebStorage" value="cloud" />
          <preference name="DisallowOverscroll" value="false" />
          <preference name="EnableViewportScale" value="false" />
          <preference name="KeyboardDisplayRequiresUserAction" value="true" />
          <preference name="MediaPlaybackRequiresUserAction" value="false" />
          <preference name="SuppressesIncrementalRendering" value="false" />
          <preference name="SuppressesLongPressGesture" value="false" />
          <preference name="Suppresses3DTouchGesture" value="false" />
          <preference name="GapBetweenPages" value="0" />
          <preference name="PageLength" value="0" />
          <preference name="PaginationBreakingMode" value="page" />
          <preference name="PaginationMode" value="unpaginated" />
          <preference name="StatusBarOverlaysWebView" value="false" />
          <feature name="StatusBar">
              <param name="ios-package" value="CDVStatusBar" />
              <param name="onload" value="true" />
          </feature>
          <preference name="StatusBarOverlaysWebView" value="true" />
          <preference name="StatusBarStyle" value="lightcontent" />
      </widget>
      

      But, if you run the prepare command another time (which we did in step 12) the file looks like this:

      <?xml version='1.0' encoding='utf-8'?>
      <widget id="io.cordova.hellocordova" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
          <feature name="LocalStorage">
              <param name="ios-package" value="CDVLocalStorage" />
          </feature>
          <feature name="HandleOpenUrl">
              <param name="ios-package" value="CDVHandleOpenURL" />
              <param name="onload" value="true" />
          </feature>
          <feature name="IntentAndNavigationFilter">
              <param name="ios-package" value="CDVIntentAndNavigationFilter" />
              <param name="onload" value="true" />
          </feature>
          <feature name="GestureHandler">
              <param name="ios-package" value="CDVGestureHandler" />
              <param name="onload" value="true" />
          </feature>
          <feature name="StatusBar">
              <param name="ios-package" value="CDVStatusBar" />
              <param name="onload" value="true" />
          </feature>
          <name>HelloCordova</name>
          <description>
              A sample Apache Cordova application that responds to the deviceready event.
          </description>
          <author email="dev@cordova.apache.org" href="http://cordova.io">
              Apache Cordova Team
          </author>
          <content src="index.html" />
          <access origin="*" />
          <allow-intent href="http://*/*" />
          <allow-intent href="https://*/*" />
          <allow-intent href="tel:*" />
          <allow-intent href="sms:*" />
          <allow-intent href="mailto:*" />
          <allow-intent href="geo:*" />
          <allow-intent href="itms:*" />
          <allow-intent href="itms-apps:*" />
          <preference name="AllowInlineMediaPlayback" value="false" />
          <preference name="BackupWebStorage" value="cloud" />
          <preference name="DisallowOverscroll" value="false" />
          <preference name="EnableViewportScale" value="false" />
          <preference name="KeyboardDisplayRequiresUserAction" value="true" />
          <preference name="MediaPlaybackRequiresUserAction" value="false" />
          <preference name="SuppressesIncrementalRendering" value="false" />
          <preference name="SuppressesLongPressGesture" value="false" />
          <preference name="Suppresses3DTouchGesture" value="false" />
          <preference name="GapBetweenPages" value="0" />
          <preference name="PageLength" value="0" />
          <preference name="PaginationBreakingMode" value="page" />
          <preference name="PaginationMode" value="unpaginated" />
          <preference name="StatusBarOverlaysWebView" value="false" />
          <preference name="StatusBarStyle" value="lightcontent" />
      </widget>
      

      Please note two things: The first is, that <feature name="StatusBar"> has been moved to the top in the second file. But in the first file (so after the first time prepare) the setting StatusBarOverlaysWebView has been defined twice. The first time with value false what we actually want and the second time with value true, which we don't want, but is the default of the plugin. For sure, this second setting overwrites the value we want to have.
      The second prepare command then removes the setting with the value true, so the config.xml has that setting only once with the value we want.

      Attachments

        1. Result of Step 10.png
          60 kB
          Manuel Rauber
        2. Result of Step 13.png
          47 kB
          Manuel Rauber

        Issue Links

          Activity

            People

              Unassigned Unassigned
              ManuelRauber Manuel Rauber
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: