Search code examples
cordovacordova-pluginsvisual-studio-cordova

Adding plugin parameters through config.xml in Visual Studio doesn't work


I am using VS2013 Update 4 with Apache Cordova Tools CTP 3.1. I have been struggling with installing two plugins where both of them use the <preference> tag in their plugin.xml.

It is basically the same as this but the suggestions in the answers don't seem to help at all. It also seems like the problem is not specific to the Facebook Connect plugin, hence this new question.

https://msdn.microsoft.com/en-us/library/dn757051.aspx#Configuring shows that adding parameters to plugins is supported through config.xml but I didn't have any luck with it so far.

<vs:plugin name="com.phonegap.plugins.facebookconnect" version="0.8.1">
    <param name="APP_ID" value="12345678" />
    <param name="APP_NAME" value="My Facebook App" />
</vs:plugin>

I get:

TypeError: Cannot use 'in' operator to search for 'APP_ID' in undefined

Same goes for the following plugin: https://github.com/EddyVerbruggen/Custom-URL-scheme

<vs:plugin name="nl.x-services.plugins.launchmyapp" version="3.2.2">
    <param name="URL_SCHEME" value="appname" />
</vs:plugin>

where I get:

TypeError: Cannot use 'in' operator to search for URL_SCHEME' in undefined

I have been struggling with this for a while now but there doesn't seem to be a solution. Has anyone seen the same problem and if so, found a solution?


Solution

  • Unfortunately, due to a Cordova issue, you can run into problems with plugin variables in Cordova < 5.0.0. Plugin variable information is lost if you install the "plugin" be fore the "platform" which can happen depending on your workflow. They do, however, function in Cordova 5.0.0 which you can use with VS 2015 RC. To update to 5.0.0 and use plugin variables, you will need to update your VS project and use the command line.

    1. Remove the plugins with the variables via the config designer.
    2. Update to Cordova 5.0.0 via the config designer (Platforms > Cordova CLI)
    3. From the command line:
      1. Go to your project directory.
      2. Type the following substituting the plugin name for the plugin you wish to add:
        1. npm install -g cordova
        2. cordova plugin add nl.x-services.plugins.launchmyapp --variable URL_SCHEME=myscheme

    This issue is actively being worked so things should improve in the future. You will also want to take note of the additional known issues pertaining to 5.0.0 when using it.

    https://www.visualstudio.com/explore/cordova-known-issues-vs

    You will also want to note the bug reported for the Facebook for the Cordova plugin registry when building for iOS. This will also likely cause issues with VS due to the NTFS file-system on Windows. Here is a possible fix for this problem: https://github.com/Chuxel/taco-tricks/tree/master/ios-plugin-symlink-fix