How to to include 'edit-config' tag in mobile-config.js?

I need to include the following in the Cordova’s config.xml to request access to device Microphone.

<edit-config target="NSMicrophoneUsageDescription" file="*-Info.plist" mode="merge">
    <string>need microphone access to record sounds</string>
</edit-config>

How is edit-config tag maintained by using Meteor mobile-config.js?

App.appendToConfig(` <edit-config target="NSMicrophoneUsageDescription" file="*-Info.plist" mode="merge"> <string>need microphone access to record sounds</string> </edit-config> `);

Thank you for your suggestion but it doesn’t work and throwing the following error;

While preparing Cordova project for platform iOS: TypeError: doc.find is not a function at Object.resolveParent (/Users/gokhanmb/.meteor/packages/meteor-tool/.1.6.0_1.flmk1s.ontdr++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/cordova-lib/node_modules/cordova-common/src/util/xml-helpers.js:209:26)

NSLocationWhenInUseUsageDescription works in my project (Meteor 1.6.1). Please check that you include backtick symbol before <edit-config> and after </edit-config>

App.appendToConfig(` <edit-config target="NSLocationWhenInUseUsageDescription" file="*-Info.plist" mode="merge"> <string>need location... </string> </edit-config> `);

Yes, you are right. I try your code and it works. But when I change the target from NSLocationWhenInUseUsageDescription to NSMicrophoneUsageDescription it fails :grimacing::grimacing::grimacing:

Oh, finally it works with the following;


App.appendToConfig(`
  <edit-config target="NSMicrophoneUsageDescription" file="*-Info.plist" mode="merge">
    <string>Need microphone access to record voice</string>
  </edit-config>
`);

Thank you!

This has never, and on 1.8 still does not, work for me. I get the doc.find error if I use *-Info.plist and I get no error but no success if I use a full path to my plist file. My edit-configs end up in the config.xml if I use the full path, but *-Info.plist crashes the build with the doc.find error, so there’s no output at all. I have other App.appendToConfig() statements that all work, but this just doesn’t.

So, I’m curious – how are users of *-Info.plist making it work? And why does an edit-config with a full path make it into config.xml but not update the file?

Fails with doc.find error:

App.appendToConfig(`
<platform name="ios">
  <splash src="../../../splash/Default@2x~universal~anyany.png" />
  <splash src="../../../splash/Default@3x~universal~anyany.png" />
  <splash src="../../../splash/Default@2x~universal~comany.png" />
  <splash src="../../../splash/Default@3x~universal~comany.png" />
  <edit-config target="NSLocationWhenInUseUsageDescription" file="*-Info.plist" mode="overwrite">
    <string>Allows access to your location for navigation purposes</string>
  </edit-config>
</platform>
`);

With full path, goes into config.xml like this, but doesn’t affect the plist file:

...
    <allow-navigation href="*" />
    <splash src="../../../splash/Default@2x~universal~anyany.png" />
    <splash src="../../../splash/Default@3x~universal~anyany.png" />
    <splash src="../../../splash/Default@2x~universal~comany.png" />
    <splash src="../../../splash/Default@3x~universal~comany.png" />
    <edit-config file="/Users/opx/builds_dev/ios/project/MyApp/MyApp-Info.plist" mode="merge" target="NSBluetoothPeripheralUsageDescription">
        <string>Uses Bluetooth to improve determining your location</string>
    </edit-config>
    <edit-config file="/Users/opx/builds_dev/ios/project/MyApp/MyApp-Info.plist" mode="overwrite" target="NSLocationWhenInUseUsageDescription">
        <string>Allows access to your location for navigation purposes</string>
    </edit-config>
    <icon height="1024" src="resources/app_store.icon.png" width="1024" />
...

Here’s more. I realized that i get this warning for each of my failed full-path edit-configs:

% config file /Users/opx/builds_dev/ios/project/MyApp/MyApp-Info.plist requested
for changes not found at
/Users/opx/myapp/.meteor/local/cordova-build/platforms/ios/Users/opx/builds_dev/ios/project/MyApp/MyApp-Info.plist, ignoring

But then if I change my full path to just “MyApp-Info.plist” and run another build, I get the above AGAIN, plus:

%% config file MyApp-Info.plist requested for changes not found at 
/Users/opx/myapp/.meteor/local/cordova-build/platforms/ios/MyApp-Info.plist, ignoring

So this build is:

  1. Reusing stuff from the prior build (bad)
  2. Appending the entirety of the file=“whatever.plist” edit-config entry to the path /Users/opx/myapp/.meteor/local/cordova-build/platforms/ios/ (also bad)

Which may mean that no config other than file="*-Info.plist" can ever work, because of some esoterica about the search capability of the * causing it to get around the strange pathing. It may also mean that those people for whom this is working are only getting it to work because it works on subsequent builds due to reusing some part of a prior failed build. Seems there’s a lot not right here. Can anyone help?

Well, I found this: https://stackoverflow.com/questions/47404622/edit-config-for-ios-usage-descriptions-doc-find-is-not-a-function

Which caused me to do some deleting of build directories and rebuilding, and I also created a hook script to work around an android Cordova issue with minSdkVersion that was causing an initial build to fail and require a 2nd build, and voila! Now it works. So, I think there is something to the reusing cached parts of the build that causes this not to work.