【问题标题】:Cordova iOS build fails with 'edit-config' tagCordova iOS 构建失败并带有“edit-config”标签
【发布时间】:2018-06-12 09:47:52
【问题描述】:

我有一个 Ionic 3 应用程序(Ionic CLI 3.19.0、Cordova CLI 8.0.0、android 平台 7.0.0、 ios 平台 4.5.4),包括本机“地理定位”插件。由于 iOS 10+ 需要 App-Info.plist 文件中的 NSLocationWhenInUseUsageDescription 属性,因此插件的文档 (Geolocation iOS Quirks) 表示在 config.xml 中包含以下内容:

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

所以我将它逐字添加为我的 config.xml 的 &lt;platform name="ios"&gt;...&lt;/platform&gt; 标记中的第一个条目。

在构建的 cordova iOS 阶段,它失败并出现以下模糊错误:

(node:60604)UnhandledPromiseRejectionWarning: 未处理的承诺拒绝 (rejection id: 1): TypeError: doc.find is not a function

(node:60604) [DEP0018] DeprecationWarning:不推荐使用未处理的承诺拒绝。将来,未处理的 Promise 拒绝将使用非零退出代码终止 Node.js 进程。

【问题讨论】:

  • 我发现删除然后添加 iOS 平台可以解决问题。但是,这会破坏一些使用的插件,因为它们需要先安装平台。因此,我必须重新安装这些插件。

标签: ios cordova ionic-framework cordova-plugins


【解决方案1】:

正如上面评论中提到的,所需的步骤是:

  • 删除平台 ios:cordova 平台删除 ios
  • edit-config 添加到 platform name="ios" 标签中

    &lt;platform name="ios"&gt; Add me here &lt;/platform&gt;

  • 运行准备 ios:ionic cordova prepare ios

【讨论】:

  • 连同这个答案,这个其他答案 (stackoverflow.com/a/48182065/763010) 帮助我识别了 ios.json 文件中任何现有的 NS* 字符串,然后我能够将其迁移到 config.xml 文件作为&lt;platform name="ios"&gt; 标记中的新条目,从而保留所有现有值。
【解决方案2】:

并将其设置为正确的格式

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

【讨论】:

    猜你喜欢
    • 2018-07-05
    • 2018-06-07
    • 1970-01-01
    • 2016-03-27
    • 1970-01-01
    • 1970-01-01
    • 2018-08-28
    • 2019-07-28
    • 1970-01-01
    相关资源
    最近更新 更多