Cordova plugins stop working, need to remove and re-add them (too) often

时间:2016-08-31 12:23:48

标签: cordova cordova-plugins cordova-cli

I'm working on a cordova project that needs to be deployed on both Android and iOS and I'm having some issues with plugins I installed via cordova cli (command line interface).

This ONLY seems to happen on the iOS side of things but that could be because I mostly work on a Windows machine and push changes to a mac and build the iOS app there (see below)

The only way to fix it is to remove the plugin (cordova plugin remove [plugin] --save) and then add it again (cordova plugin add [plugin] --save). It's happened with both StatusBar and SocialSharing plugins.

Some background:

  • I work on multiple machines. Two of those are windows on which I do most of the work and build the Android app. The other is a mac. I use that one as little as possible (I don't like OSX and mac keyboard shortcuts) but I need it to build the iOS app.

  • I sync between the machines via subversion (svn). I ignore the platforms/ and plugins/ folders so it's basically only the www/ folder and the config.xml that change. After a 'svn up' I run cordova prepare.

  • I use Cordova 6.3.1, iOS platform 4.2.1, OSX El Capitan

Oh, whenever I call the plugin in javascript code it doesn't throw any errors. It just doesn't work, nothing happens.

Am I doing something wrong? Is this a bug, maybe?

UPDATE

Config.xml:

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.example.app" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>AppName</name>
    <description>
        Blabla
    </description>
    <author email="email@host.com" href="http://website.com/">
        Me!
    </author>
    <content src="index.html" />
    <plugin name="cordova-plugin-whitelist" spec="1" />
    <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:*" />
    <platform name="android">
        <allow-intent href="market:*" />
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
    </platform>
    <plugin name="cordova-plugin-statusbar" spec="~2.1.3" />
    <feature name="StatusBar">
        <param name="ios-package" onload="true" value="CDVStatusBar" />
    </feature>
    <preference name="StatusBarOverlaysWebView" value="false" />
    <preference name="StatusBarStyle" value="lightcontent" />
    <preference name="StatusBarBackgroundColor" value="#5ca829" />
    <feature name="SocialSharing">
        <param name="ios-package" value="SocialSharing" />
        <param name="android-package" value="nl.xservices.plugins.SocialSharing" />
    </feature>
    <plugin name="cordova-plugin-x-socialsharing" spec="~5.1.2" />
    <engine name="android" spec="~5.2.2" />
    <engine name="ios" spec="~4.2.1" />
</widget>

(The config is a bit of a mess but that's because cordova keeps shuffling things around, I've given up on keeping it tidy at least for now)

Plugins that are affected (yep, it's multiple):

  • cordova-plugin-statusbar

  • cordova-plugin-x-socialsharing

It seems to happen every time I add a plugin on machine X and then check it out on machine Y (the latter being the mac) which causes cordova prepare to install the plugins that are declared in the config but are not found on the system. I've also tested by removing the platforms/ and(/or) plugins/ folder and then run 'cordova prepare', I get the same problem.

It seems the prepare commando does add them but not properly? Maybe?

0 个答案:

没有答案