简体   繁体   中英

Cordova Plugin.xml writing undefined key in to info.plist

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

<?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.

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

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

  • Plugins have a file 'plugin.xml', look for xml that starts with <config-file>
  • The same type of markup can be added in your main config.xml
  • The third location, and the source of my trouble was in platform/ios/ios.json

ios.json stores configurations made manually within Xcode and applies them when you run $ 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.

<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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM