Cordova iOS build fails with 'edit-config'

2019-05-09 01:27发布

问题:

I have an Ionic 3 app (Ionic CLI 3.19.0, Cordova CLI 8.0.0, android platform 7.0.0, ios platform 4.5.4) that includes the native 'Geolocation' plugin. Since iOS 10+ requires the NSLocationWhenInUseUsageDescription property in the App-Info.plist file, the plugin's documentation (Geolocation iOS Quirks) says to include the following in the config.xml:

<edit-config target="NSLocationWhenInUseUsageDescription" file="*-Info.plist" mode="merge">
   <string>need location access to find things nearby</string>
</edit-config>

So I added that verbatim as the first entry within <platform name="ios">...</platform> tag of my config.xml.

During the cordova iOS stage of the build, it fails with the following obscure errors:

(node:60604)UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: doc.find is not a function

(node:60604) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

回答1:

As mentioned in the comment above, the steps needed are:

  • Remove platforms ios: cordova platform remove ios
  • Add the edit-config into platform name="ios" tag

    <platform name="ios"> Add me here </platform>

  • Run prepare ios: ionic cordova prepare ios



回答2:

and set it in the right format

<edit-config parent="NSLocationWhenInUseUsageDescription" target="*-Info.plist">
    <string>need location access to to order a driver to the current location</string>
</edit-config>