apache / cordova-common

Apache Cordova Common Tooling Library
https://cordova.apache.org/
Apache License 2.0
39 stars 46 forks source link

doc.find is not a function #156

Closed WuglyakBolgoink closed 3 years ago

WuglyakBolgoink commented 3 years ago

Bug Report

Problem

What is expected to happen?

cordova prepare should be finished successful

What does actually happen?

ios prepare finished with doc.find is not a function

doc.find is not a function
TypeError: doc.find is not a function
    at Object.resolveParent (/Users/.../.npm-global/lib/node_modules/cordova/node_modules/cordova-common/src/util/xml-helpers.js:131:51)

the problem is on this code block image

Information

The /cordova_v10_staging/platforms/ios/ios.json file contain only two permission descriptions in config_munge.files.*-Info.plist section:

image

should contain all permissions

my ios config:

<platform name="ios">
    <icon src="res/ios/icon/icon-20.png" width="20" height="20"/>
    <icon src="res/ios/icon/icon-20@2x.png" width="40" height="40"/>
    <icon src="res/ios/icon/icon-20@3x.png" width="60" height="60"/>
    <icon src="res/ios/icon/icon-24@2x.png" width="48" height="48"/>
    <icon src="res/ios/icon/icon-27.5@2x.png" width="55" height="55"/>
    <icon src="res/ios/icon/icon-29.png" width="29" height="29"/>
    <icon src="res/ios/icon/icon-29@2x.png" width="58" height="58"/>
    <icon src="res/ios/icon/icon-29@3x.png" width="87" height="87"/>
    <icon src="res/ios/icon/icon-40.png" width="40" height="40"/>
    <icon src="res/ios/icon/icon-40@2x.png" width="80" height="80"/>
    <icon src="res/ios/icon/icon-40@3x.png" width="120" height="120"/>
    <icon src="res/ios/icon/icon-44@2x.png" width="88" height="88"/>
    <icon src="res/ios/icon/icon-50.png" width="50" height="50"/>
    <icon src="res/ios/icon/icon-50@2x.png" width="100" height="100"/>
    <icon src="res/ios/icon/icon-60.png" width="60" height="60"/>
    <icon src="res/ios/icon/icon-60@2x.png" width="120" height="120"/>
    <icon src="res/ios/icon/icon-60@3x.png" width="180" height="180"/>
    <icon src="res/ios/icon/icon-72.png" width="72" height="72"/>
    <icon src="res/ios/icon/icon-72@2x.png" width="144" height="144"/>
    <icon src="res/ios/icon/icon-76.png" width="76" height="76"/>
    <icon src="res/ios/icon/icon-76@2x.png" width="152" height="152"/>
    <icon src="res/ios/icon/icon-83.5@2x.png" width="167" height="167"/>
    <icon src="res/ios/icon/icon-86@2x.png" width="172" height="172"/>
    <icon src="res/ios/icon/icon-98@2x.png" width="196" height="196"/>
    <icon src="res/ios/icon/icon-108@2x.png" width="216" height="216"/>
    <icon src="res/ios/icon/icon-1024.png" width="1024" height="1024"/>
    <icon src="res/ios/icon/icon.png" width="57" height="57"/>
    <icon src="res/ios/icon/icon@2x.png" width="114" height="114"/>
    <!-- Default image to be used for all modes -->
    <splash src="res/ios/splash/Default@2x~universal~anyany.png"/>
    <allow-intent href="itms:*"/>
    <allow-intent href="itms-apps:*"/>
    <preference name="deployment-target" value="11.0"/>
    <preference name="iosPersistentFileLocation" value="Library"/>
    <preference name="BackupWebStorage" value="none"/>
    <edit-config file="*-Info.plist" mode="merge" target="NSContactsUsageDescription">
      <string>Der Zugriff wird verwendet, um Kontaktdaten zur Auswahl zu stellen</string>
    </edit-config>
    <edit-config file="*-Info.plist" mode="merge" target="NSPhotoLibraryUsageDescription">
      <string>Der Zugriff wird verwendet, um Fotos zur Auswahl zu stellen</string>
    </edit-config>
    <edit-config file="*-Info.plist" mode="merge" target="NSCameraUsageDescription">
      <string>Der Zugriff wird verwendet, um die Aufnahme von Fotos zur Auswahl zu stellen</string>
    </edit-config>
    <edit-config file="*-Info.plist" mode="merge" target="NSMicrophoneUsageDescription">
      <string>Der Zugriff wird verwendet, um für ein Video die Tonaufnahme zu aktivieren</string>
    </edit-config>
    <edit-config file="*-Info.plist" mode="merge" target="ITSAppUsesNonExemptEncryption">
      <false/>
    </edit-config>
    <edit-config file="*-Info.plist" mode="merge" target="CFBundleDevelopmentRegion">
      <string>de_DE</string>
    </edit-config>
    <edit-config file="*-Info.plist" target="LSApplicationQueriesSchemes" mode="merge">
      <array>
        <string>cydia</string>
      </array>
    </edit-config>
    <edit-config file="*-Info.plist" target="UISupportedInterfaceOrientations" mode="overwrite">
      <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationPortraitUpsideDown</string>
      </array>
    </edit-config>
    <!-- Set orientation on iPad -->
    <edit-config file="*-Info.plist" target="UISupportedInterfaceOrientations~ipad" mode="overwrite">
      <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationPortraitUpsideDown</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
      </array>
    </edit-config>
    <preference name="WKWebViewOnly" value="true"/>
    <preference name="CordovaWebViewEngine" value="CDVWKWebViewEngine"/>
    <feature name="CDVWKWebViewEngine">
      <param name="ios-package" value="CDVWKWebViewEngine"/>
    </feature>
  </platform>

Command or Code

I use simple bash script for cleaning, install and upgrade plugins and platforms. In this case I just use clean function

function clean_cordova_project_folder() {
    cd "$1" || exit

    echo "clean_cordova_project_folder -> $1"

   #  rm -rf node_modules
    rm -rf platforms
    rm -rf plugins
    rm -rf ul_web_hooks
    rm -rf package-lock.json

    npm install

    cordova prepare --verbose --debug

    cd ..
}

APP_FOLDER_STAGE="<yout_cordova_project_folder>" 
# 1. clean folders and install packages
clean_cordova_project_folder "$APP_FOLDER_STAGE"

Environment, Platform, Device

Version information

Checklist

raphinesse commented 3 years ago

Thanks for your bug report. Could you please:

WuglyakBolgoink commented 3 years ago

@raphinesse I try to find a 100% reproducible case...

But now only stacktrace:

Prepared iOS project successfully
doc.find is not a function
TypeError: doc.find is not a function
    at Object.resolveParent (/Users/xxxxx/.npm-global/lib/node_modules/cordova/node_modules/cordova-common/src/util/xml-helpers.js:132:24)
    at /Users/xxxxx/.npm-global/lib/node_modules/cordova/node_modules/cordova-common/src/ConfigChanges/ConfigChanges.js:315:59
    at Array.forEach (<anonymous>)
    at PlatformMunger._is_conflicting (/Users/xxxxx/.npm-global/lib/node_modules/cordova/node_modules/cordova-common/src/ConfigChanges/ConfigChanges.js:307:21)
    at PlatformMunger.add_config_changes (/Users/xxxxx/.npm-global/lib/node_modules/cordova/node_modules/cordova-common/src/ConfigChanges/ConfigChanges.js:176:44)
    at /Users/xxxxx/.npm-global/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/prepare/platforms.js:66:24
    at async Promise.all (index 0)
WuglyakBolgoink commented 3 years ago

@raphinesse

What I have:


  1. create cordova project
cordova create test157 com.example.test157 test157
  1. open folder
cd test157
  1. install ios platform
cordova platform add ios@6.2.0
  1. Do prepare -> this should be OK
cordova prepare --verbose --debug
  1. Add this two commented edit-config's into ios section

6. Do prepare -> this should be OK

```bash
cordova prepare --verbose --debug
  1. Uncomment first config
        <edit-config file="*-Info.plist" mode="merge" target="NSContactsUsageDescription">
            <string>NSContactsUsageDescription test</string>
        </edit-config>
  1. Do prepare -> this should be OK
cordova prepare --verbose --debug
  1. Uncomment second config
        <edit-config file="*-Info.plist" mode="merge" target="NSPhotoLibraryUsageDescription">
            <string>NSPhotoLibraryUsageDescription test</string>
        </edit-config>
  1. this should throw an error
cordova prepare --verbose --debug
Prepared iOS project successfully
doc.find is not a function
TypeError: doc.find is not a function
    at Object.resolveParent (/Users/xxxUSERxxx/.npm-global/lib/node_modules/cordova/node_modules/cordova-common/src/util/xml-helpers.js:132:24)
    at /Users/xxxUSERxxx/.npm-global/lib/node_modules/cordova/node_modules/cordova-common/src/ConfigChanges/ConfigChanges.js:315:59
    at Array.forEach (<anonymous>)
    at PlatformMunger._is_conflicting (/Users/xxxUSERxxx/.npm-global/lib/node_modules/cordova/node_modules/cordova-common/src/ConfigChanges/ConfigChanges.js:307:21)
    at PlatformMunger.add_config_changes (/Users/xxxUSERxxx/.npm-global/lib/node_modules/cordova/node_modules/cordova-common/src/ConfigChanges/ConfigChanges.js:176:44)
    at /Users/xxxUSERxxx/.npm-global/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/prepare/platforms.js:66:24
    at async Promise.all (index 0)
raphinesse commented 3 years ago

Thanks for the quick response. I'll try to take a look at this soon.

raphinesse commented 3 years ago

I can confirm the error occurs on my machine too.

raphinesse commented 3 years ago

I just created a PR to fix this issue. It would be great if you could test if it resolves your problem.

WuglyakBolgoink commented 3 years ago

Thank you @raphinesse !

I will check it on this week