Comments (14)
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.
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.
@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.
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.
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.
@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.
+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.
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.
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.
@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.
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.
@dpa99c PR #92 if you would be so kind :)
from cordova-custom-config.
@dpa99c Have fixed this one now for good with #93
from cordova-custom-config.
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)
- Android: custom-preference isn't doing anything, no error given HOT 1
- not compatible with cordova 9
- iOS location issue on uploading the apptore - ask for NSLocationAlwaysUsageDescription HOT 2
- All of a sudden (after updating node/npm LTS and cordova to 8.1.2), upon 'cordova run android', "Error loading dependencies (Cannot find module 'tostr') - attempting to resolve" - must install all deps by hand now HOT 6
- cordova-custom-config: Error updating config for platform 'android': Cannot use absolute path on element HOT 2
- Cordova builds fail with XCode-beta 11 HOT 4
- i need help with error unboun prefix HOT 1
- Question: iOS - how to set Legacy Build System ? HOT 5
- Builds fail when attempting usesClearText=true HOT 1
- Cordova ios build error - can someone help HOT 1
- Question: is this plugin needed for UISupportedInterfaceOrientations? HOT 2
- support capacitor HOT 1
- [Bug][Android] '"{{proj_path}}\platforms\android\cordova\version"' is not recognized as an internal or external command, operable program or batch file. HOT 1
- Cannot insert new Item to the section on AndroidManifest
- Vulnerability with package 'colors' HOT 1
- vulnerability in xcode package HOT 1
- Config.xml Bug HOT 6
- Ionic - The prefix "tools" for attribute "tools:node" associated with an element type "uses-permission" is not bound. HOT 1
- cordova-ios renamed Images.xcassets as Assets.xcassets meaning that asset_catalog needs to be updated
- BSF Cordova Ecosystem Crowdfunding Plan
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cordova-custom-config.