Cordova Plugin.xml将未定义的密钥写入info.plist

时间:2023-01-20 16:21:18

Im creating a small plugin that exists only to write some values to the info.plist for the app. the following is the code from the plugin.xml

我创建一个小插件,只存在为应用程序的info.plist写一些值。以下是plugin.xml中的代码

<?xml version="1.0" encoding="UTF-8"?>

<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
    id="com.example.fileshare"
    version="1.0.0">
<name>Example Fileshare Enable</name>
<description>Enables Filesharing</description>
<license>Apache 2.0</license>

<!-- iOS -->
   <platform name="ios">
      <config-file target="*-Info.plist">
        <key>CFBundleDisplayName</key>
        <string>${PRODUCT_NAME}</string>
        <key>UIFileSharingEnabled</key>
        <true/>
      </config-file>
   </platform>

</plugin>

From this code the CFBundleDisplayName is being writen to the info.plist just fine however the UIFileSharingEnabled is being written as a boolean with a key of undefined.

从这段代码中可以很好地将CFBundleDisplayName写入info.plist,但是UIFileSharingEnabled被写为带有未定义键的布尔值。

Im unsure what is causing this but i would really appreciate some guidance.

我不确定是什么导致了这一点,但我真的很感激一些指导。

1 个解决方案

#1


0  

I had this same issue, what I learned is that the info.plist file is populated from up to three different sources.

我有同样的问题,我学到的是info.plist文件最多可以填充三个不同的来源。

  • Plugins have a file 'plugin.xml', look for xml that starts with <config-file>
  • 插件有一个文件'plugin.xml',查找以 开头的xml

  • The same type of markup can be added in your main config.xml
  • 可以在主config.xml中添加相同类型的标记

  • The third location, and the source of my trouble was in platform/ios/ios.json
  • 第三个位置,我的麻烦来源是platform / ios / ios.json

ios.json stores configurations made manually within Xcode and applies them when you run $ cordova prepare ios

ios.json存储在Xcode中手动进行的配置,并在运行$ cordova prepare ios时应用它们

My fix was to remove the offending lines within ios.json and remove all of the offending lines from the info.plist file. In my case I was able to add the configuration manually to my config.xml.

我的修复是删除ios.json中的违规行,并从info.plist文件中删除所有违规行。在我的情况下,我能够手动将配置添加到我的config.xml。

<config-file parent="ITSAppUsesNonExemptEncryption" target="*-Info.plist">
    <false />
</config-file>

If you have the same configuration set in multiple places one will always win out.

如果您在多个位置设置相同的配置,则总会赢得胜利。

#1


0  

I had this same issue, what I learned is that the info.plist file is populated from up to three different sources.

我有同样的问题,我学到的是info.plist文件最多可以填充三个不同的来源。

  • Plugins have a file 'plugin.xml', look for xml that starts with <config-file>
  • 插件有一个文件'plugin.xml',查找以 开头的xml

  • The same type of markup can be added in your main config.xml
  • 可以在主config.xml中添加相同类型的标记

  • The third location, and the source of my trouble was in platform/ios/ios.json
  • 第三个位置,我的麻烦来源是platform / ios / ios.json

ios.json stores configurations made manually within Xcode and applies them when you run $ cordova prepare ios

ios.json存储在Xcode中手动进行的配置,并在运行$ cordova prepare ios时应用它们

My fix was to remove the offending lines within ios.json and remove all of the offending lines from the info.plist file. In my case I was able to add the configuration manually to my config.xml.

我的修复是删除ios.json中的违规行,并从info.plist文件中删除所有违规行。在我的情况下,我能够手动将配置添加到我的config.xml。

<config-file parent="ITSAppUsesNonExemptEncryption" target="*-Info.plist">
    <false />
</config-file>

If you have the same configuration set in multiple places one will always win out.

如果您在多个位置设置相同的配置,则总会赢得胜利。