Coder Social home page Coder Social logo

Comments (14)

dpa99c avatar dpa99c commented on August 15, 2024

From your description, I don't understand the specific problem. By this, do you mean that another plugin is making changes to a platform config and that these changes are being lost when this plugin applies its changes? Because this plugin doesn't directly write to the config.xml

If this is the case, please post your config.xml and the verbose console output of the prepare or build operation which illustrates the issue

from cordova-custom-config.

becvert avatar becvert commented on August 15, 2024

Hi. I think I have the same issue.

For instance, one of my "custom-config" blocks in config.xml is:

<config-file parent="LSApplicationQueriesSchemes" platform="ios" target="*-Info.plist">
            <array>
                <string>itms-apps</string>
                <string>twitter</string>
                <string>fb</string>
                <string>belote-rebelote-free</string>
                <string>belote-rebelote-paid</string>
                <string>tarot-africain-free</string>
                <string>tarot-africain-paid</string>
            </array>
        </config-file>

And I'm using the Facebook4 cordova plugin which add in the .plist:

<key>LSApplicationQueriesSchemes</key>
    <array>
      <string>fbapi</string>
      <string>fb-messenger-api</string>
      <string>fbauth2</string>
      <string>fbshareextension</string>
    </array>

so I should have this as the result:

<key>LSApplicationQueriesSchemes</key>
    <array>
      <string>itms-apps</string>
      <string>twitter</string>
      <string>fb</string>
      <string>belote-rebelote-free</string>
      <string>belote-rebelote-paid</string>
      <string>tarot-africain-free</string>
      <string>tarot-africain-paid</string>
      <string>fbapi</string>
      <string>fb-messenger-api</string>
      <string>fbauth2</string>
      <string>fbshareextension</string>
    </array>

it turns out that I only get this:

<key>LSApplicationQueriesSchemes</key>
    <array>
      <string>itms-apps</string>
      <string>twitter</string>
      <string>fb</string>
      <string>belote-rebelote-free</string>
      <string>belote-rebelote-paid</string>
      <string>tarot-africain-free</string>
      <string>tarot-africain-paid</string>
    </array>

I must re-install Facebook4 to get what I want.
That plugin is able to merge blocks somehow.
"Custom-config" blocks should merge with existing ones too.

I think it's a possible duplicate of #30

Thank you. awesome plugin otherwise!

from cordova-custom-config.

dpa99c avatar dpa99c commented on August 15, 2024

@becvert from the info you've posted, I can see what's happening: currently this plugin does not parse the contents of config-file blocks, it merely replicates the contents verbatim inside of the specified root node. So if the root node already exists in the platform config (in this case it does as LSApplicationQueriesSchemes), the existing values will be replaced by those defined in the config block.

In order to merge rather than replace, the plugin would need to parse and process the config-file block contents as XML nodes rather than plain text.

The Facebook4 plugin has hard-coded values for this root node, so simply defines them in its plugin.xml and lets Cordova handle the merge.

If/when I have time, I will make this enhancement to the plugin.

from cordova-custom-config.

becvert avatar becvert commented on August 15, 2024

great. thank you.

as a workaround for now, I change the hook's type in your plugin.xml from

<hook src="hooks/applyCustomConfig.js" type="after_prepare" />

to

<hook src="hooks/applyCustomConfig.js" type="before_prepare" />

in order to let the Facebook4 plugin or rather cordova itself do the merge.

from cordova-custom-config.

ivynye avatar ivynye commented on August 15, 2024

It looks like becvert has the same issue. We're using a custom-config block to set some ios preference, here are a few:

        <config-file parent="UIStatusBarHidden" platform="ios" target="*-Info.plist">
            <true />
        </config-file>
        <config-file parent="UIViewControllerBasedStatusBarAppearance" platform="ios" target="*-Info.plist">
            <false />
        </config-file>

We just recently started to implement the cordova-plugin-tag-manager, which also has some tags configured.

I also discovered that timing on the applyCustomConfig hook was the source of the issue.

I can actually watch the .plist get appended by my config, and then see that it is overwritten by the plugin's config.

from cordova-custom-config.

dpa99c avatar dpa99c commented on August 15, 2024

@ivynye is your issue exactly the same as @becvert? i.e. the other plugin is creating config entries with the same element names and this plugin is overwriting those? Or is your issue that the other plugin is creating entirely different config entries yet the changes are being lost anyway?

I can understand that in @becvert's case, setting the hook to run before_prepare solved the issue because this plugin was overwriting elements that had previous been created by the Facebook plugin.

However, if I set the plugin to always do this by default, then it loses the ability to override defaults that are set by Cordova during the prepare operation (running after_prepare enables this). One quick solution I could implement is to allow a custom preference in the config.xml which enables this to be specified (e.g. <preference name="cordova-custom-config-hook" value="before_prepare|after_prepare" />). Would that solve your issues?

from cordova-custom-config.

Ajaxy avatar Ajaxy commented on August 15, 2024

+1 here.
Would be great to have overwrite parameter as it's done in PhoneGap Build (tree parse will be needed) — http://phonegap.com/blog/2014/01/30/customizing-your-android-manifest-and-ios-property-list-on-phonegap-build/

from cordova-custom-config.

kwvanderlinde avatar kwvanderlinde commented on August 15, 2024

This would be a welcome feature. It seems PhoneGap has replaced the overwrite attribute with the mode attribute (see docs here). I think mode is a better parameter since it gives more control than just whether or not to overwrite.

from cordova-custom-config.

pke avatar pke commented on August 15, 2024

Hitting the exact same issue as @becvert today with the facebook4 plugin.
Just switching the apply step to <hook src="hooks/applyCustomConfig.js" type="before_prepare" /> seems fishy to me and to have sideeffects @dpa99c described.

I wish cordova would have provided a annotate config functionality. That way plugins or anybody would get the current config xml and have functions like "merge nodes", "append nodes", what you have in XML manipulation.
Would make all this custom fragile hand parsing obsolete.

One other solution would be to have our own plugin with all the custom settings and install that plugin into the platform and let cordova handle the merge.

from cordova-custom-config.

pke avatar pke commented on August 15, 2024

@dpa99c I think the culprit is this line https://github.com/dpa99c/cordova-custom-config/blob/master/hooks/applyCustomConfig.js#L483

There you override whatever is in the plist already.
Couldn't that be:
infoPlist[key] = Object.assign({}, infoPlist[key], value)

from cordova-custom-config.

dpa99c avatar dpa99c commented on August 15, 2024

@pke

I wish cordova would have provided a annotate config functionality. That way plugins or anybody would get the current config xml and have functions like "merge nodes", "append nodes", what you have in XML manipulation.
Would make all this custom fragile hand parsing obsolete.

I wish the same. I created this plugin out of my own necessity, and it's becoming more and more of a pain to maintain. Ironically, I hardly use it myself anymore, so it's for the goodness of the Cordova community that I don't just unpublish the damned thing.

The support for <edit-config> blocks in config.xml added in [email protected] is a step in the right direction, but still only works for AndroidManifest.xml - no .plist support.
And <config-file> blocks are still not supported in config.xml. If Cordova supported all the same elements in config.xml as it does in plugin.xml, this plugin could be locked away in the basement.

from cordova-custom-config.

pke avatar pke commented on August 15, 2024

@dpa99c PR #92 if you would be so kind :)

from cordova-custom-config.

pke avatar pke commented on August 15, 2024

@dpa99c Have fixed this one now for good with #93

from cordova-custom-config.

edenworky avatar edenworky commented on August 15, 2024

Still running into this issue with the Facebook plugin on Android. Has a solution been found using <edit-config>? It's not apparent to me.

from cordova-custom-config.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.