【问题标题】:How do I properly add settings to an iOS app with a Cordova project?如何正确地将设置添加到带有 Cordova 项目的 iOS 应用程序?
【发布时间】:2018-04-07 15:20:42
【问题描述】:

在 Cordova 构建中,我正在尝试为我的 iOS 应用程序添加设置。我已经在Settings.bundle/Root.plist 文件中定义了这些设置。我想要的只是将Settings.bundle 及其子项复制到 XCode 项目中。

我正在尝试使用resource-file 声明来做到这一点:

<platform name="ios"> <resource-file src="res/ios/Settings.bundle" /> ... </platform>

当我进行构建时,该文件夹被添加到我的项目中 3 次,而不是仅一次,并且该文件夹中的任何文件都不会被复制。我在日志输出中看到该资源执行了 3 个CpResource 语句。

CpResource Anamnese\ mobil/Resources/res/ios/Settings.bundle build/emulator/Anamnese\ mobil.app/Settings.bundle CpResource Anamnese\ mobil/Resources/res/ios/Settings.bundle build/emulator/Anamnese\ mobil.app/Settings.bundle CpResource Anamnese\ mobil/Resources/res/ios/Settings.bundle build/emulator/Anamnese\ mobil.app/Settings.bundle

这与我在生成的 XCode 项目中看到的一致:该文件夹存在 3 次,但它没有内容。我玩弄了 Settings.bundle 的位置和里面的文件数量,看看是否与执行次数有关,但无济于事。

那么,我的问题是,如何使用 Cordova 正确地将设置添加到 iOS 应用?

或者,如果我停留在这个级别的分析:我如何正确地将文件夹结构复制到 iOS 项目中?

【问题讨论】:

    标签: ios cordova settings.bundle


    【解决方案1】:

    我没有找到为什么resource-file 添加了 3 次 Settings.bundle。但我想出了另一种将它集成到应用程序中的方法:我必须声明一个列出此 Settings.bundle 的自己的 cordova 插件。

    David Souther 在这里写了详细的说明:Cordova Phonegap IOS App Settings.Bundle Possible?

    要安装 me.apla.cordova.app-preferences,我还必须将此行包含到我的 cordova.xml

    &lt;plugin name="cordova-plugin-app-preferences" spec="https://github.com/apla/me.apla.cordova.app-preferences" /&gt;

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-06-27
      • 2015-02-15
      • 2014-03-15
      • 1970-01-01
      • 1970-01-01
      • 2021-01-29
      • 2020-08-30
      • 1970-01-01
      相关资源
      最近更新 更多