I am using the Cordova CLI (not phonegap build) and I understand that it is best practice not to version control the platform folder.
I have been looking for a solution which uses a hook to modify the contents of the android manifest or ios plist file but have not come across anything. Does anyone know if there is one available? It seems that this need is so common that there should be something available that will either merge or copy these configuration files but can’t find anything. I’m sure I could create a hook to do this, however since I’m rather new to node and since it seems so common, I dont want to spend the time if it’s already done.
Anyone have any ideas/solutions/best practices regarding this?
If anyone is interested in this hook, I have just submitted a pull request to the ionic yeoman generator that includes the new hook to modify contents of the android manifest and ios plist file similar to how you would in a plugin.xml file.
NOTE: this depends on elementree and plist npm modules, see _package.json for more info
You can view the hook in my forked repo at the following URL for more information/docs on how to use it
Yes @mirko77 . that is available as a preference. Look at the hook documentation and the mapping object which shows you all attributes available via preferences.
glad you found it useful to some extent @mcarnazzo . The only thing I would say about commenting out the lines that replace the xml rather than append is that it will break the functionality for tags that shouldn’t have more than one declaration such as supports-screens, application, or uses-sdk.
I think a good approach would be to first see if the tag can be uniquely defined (the same way I identified unique permissions in line 281), and if so, add some logic there that would uniquely select the child element and in your case, come up not found so it would append rather than replace.
If theres no way to uniquely identify an intent-filter, it may be useful to add some logic that checks a js object that stores tags/elements that CAN include multiples (such as permissions and intent-filters in your case) and always append those elements, otherwise replace.
Thank you all for sharing these!
I wonder if ionic or cordova is going to have an easier way to make changes to the platform specific manifests. I find this extremely tedious.
Yes, a more official and supported toolset for this would be great.
I just wrote a bunch of custom hook scripts to manage some plist customizations. The time to write > run/test > debug (feedback loop) is not fun. Wish I’d found these tools before I did it all myself.
@puzste take a look at the hook’s documentation here. As you will see, debuggable is not available as a preference. Also any elements other than permission elements will be replaced, so include the nested elements as well when you add configuration for AndroidManifest in config.xml.
If you post your actual config.xml code I can help you out more. It’s not clear what exactly you are trying to accomplish based on your previous posts.
The solution from @djett was great but we needed the ability to add new intent-filters to the android manifest instead of merging with the current one. I found a slightly different version of the same hook which supports optional additions instead of merges. Maybe someone who is better than me at XML could try implement the mode=“add|merge|replace|etc” options from the cordova plugin docs in which this hook is based off
Here’s the hook:
If anyone has issues running ionic build android with an error about unbound prefix’s, then you need to add this to the widget element at the top of your config.xml