98

When using the edit-config tag in config.xml, I get this error on build:

Error: doc.find is not a function

Any ideas?

Shashank Agrawal
  • 25,161
  • 11
  • 89
  • 121
Benjamin E.
  • 5,042
  • 5
  • 38
  • 65

4 Answers4

215

I think that the error has thrown when the platforms/ios/ios.json file is conflicting to the config.xml.

To resolve this issue, remove *-Info.plist key and its value in platforms/ios/ios.json and do cordova prepare ios again.

--- adding 17/May/2020 ---

If some plugins has config-file tag for *-Info.plist and config.xml has edit-config tag for *-Info.plist, this error may happen. In this case, remove platforms/* and plugins/*, and then cordova platform add ios and cordova prepare again. (If you do cordova prepare without cordova platform add ios, this error may happen)

KNaito
  • 3,930
  • 2
  • 19
  • 21
  • 10
    Nice solution considering how uninformative this crap error is! – jdixon04 Jun 28 '18 at 21:20
  • 8
    If this solution does not work for you, go to your platforms > ios > ios.json file and within the *-Info.plist parent key, add the new value that was added to the config.xml file. For example, if you add the NSPhotoLibraryUsageDescription edit-config tag, add: `"NSPhotoLibraryUsageDescription": [ { "xml": "Need photo library access to get pictures from there.", "count": 1, "mode": "merge", "id": "config.xml" } ],` – Juan Bernal Jul 30 '18 at 00:30
  • 7
    This helped but have a read on this (https://stackoverflow.com/a/48558496/1176567). If you just remove cordova ios platform and add it again, it would work. This problem occurs when ios platform is already added and then we update the config.xml with . – jsr Jan 22 '19 at 16:24
  • Just fixed the issue by using instead (other answer) – jvarandas Feb 05 '21 at 02:22
66

There is an existing issue with <edit-config> conflicting with platforms/ios/ios.json when *-Info.plist is already populated in the json file as of Cordova 7.1.0

I have fixed the issue by using <config-file> instead.

Solution:

<config-file target="*-Info.plist" parent="NSLocationWhenInUseUsageDescription">
    <string>need location access to find things nearby</string>
</config-file>
Shien Hong
  • 769
  • 5
  • 2
39

I have done this with Ionic 3. Working fine now :)

Solution:

ionic cordova platform remove ios
ionic cordova platform add ios

Re-adding the iOS platform will freshly create the ios.json file.

Shashank Agrawal
  • 25,161
  • 11
  • 89
  • 121
Sampath
  • 63,341
  • 64
  • 307
  • 441
1

Yes, brute force on this case works just fine

cordova platform rm ios && cordova platform add ios

You shouldn't care what's inside platform/ios because the directory platforms is volatile in cordova, nor should be tracked on git projects.

João Pimentel Ferreira
  • 14,289
  • 10
  • 80
  • 109