【问题标题】:iOS plist.info: where should I put additional keys with a nested dict tag?iOS plist.info:我应该在哪里放置带有嵌套 dict 标签的附加键?
【发布时间】:2016-01-28 14:00:12
【问题描述】:

在我的 Nativescript 应用程序(编译为 Native,包括 plist.info 文件)中,我正在尝试向 plist.info 添加一个密钥以解决 iOS 9 传输安全问题。

我尝试应用的解决方案来自https://blog.nraboy.com/2015/12/fix-ios-9-app-transport-security-issues-in-nativescript/

具体来说是在 plist.info 文件中添加以下键:

<key>NSAppTransportSecurity</key>  
<dict>  
    <key>NSAllowsArbitraryLoads</key>
    <true />  
</dict>

但是在构建过程中出现以下错误:

code-Info.plist':由于格式不正确,无法读取数据。

由于我是 iOS 开发的新手,我猜这是由于 XML 文件中的语法错误(特别是 将代码放在上面的位置:在关闭 plist 标记或其他之前)

我原来的 plist 文件(构建工作)是:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <string>en</string>
    <key>CFBundleDevelopmentRegion</key>
    <string>en</string>
    <key>CFBundleDisplayName</key>
    <string>${PRODUCT_NAME}</string>
    <key>CFBundleExecutable</key>
    <string>${EXECUTABLE_NAME}</string>
    <key>CFBundleIdentifier</key>
    <string>com.company.myapp</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>${PRODUCT_NAME}</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleVersion</key>
    <string>1.0</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UIRequiredDeviceCapabilities</key>
    <array>
        <string>armv7</string>
    </array>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationPortraitUpsideDown</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
</dict>
</plist>

【问题讨论】:

  • 如果需要任何帮助,请查看答案并回复

标签: ios info.plist nativescript


【解决方案1】:

这是plist语法错误

请使用这个xml。在texteditor中打开你的plist并用它替换你的xml代码。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>CFBundleDevelopmentRegion</key>
        <string>en</string>
        <key>CFBundleDisplayName</key>
        <string>${PRODUCT_NAME}</string>
        <key>CFBundleExecutable</key>
        <string>${EXECUTABLE_NAME}</string>
        <key>CFBundleIdentifier</key>
        <string>com.company.myapp</string>
        <key>CFBundleInfoDictionaryVersion</key>
        <string>6.0</string>
        <key>CFBundleName</key>
        <string>${PRODUCT_NAME}</string>
        <key>CFBundlePackageType</key>
        <string>APPL</string>
        <key>CFBundleShortVersionString</key>
        <string>1.0</string>
        <key>CFBundleSignature</key>
        <string>????</string>
        <key>CFBundleVersion</key>
        <string>1.0</string>
        <key>LSRequiresIPhoneOS</key>
        <true/>
        <key>UILaunchStoryboardName</key>
        <string>LaunchScreen</string>
        <key>UIRequiredDeviceCapabilities</key>
        <array>
            <string>armv7</string>
        </array>
        <key>UISupportedInterfaceOrientations</key>
        <array>
            <string>UIInterfaceOrientationPortrait</string>
            <string>UIInterfaceOrientationLandscapeLeft</string>
            <string>UIInterfaceOrientationLandscapeRight</string>
        </array>
        <key>UISupportedInterfaceOrientations~ipad</key>
        <array>
            <string>UIInterfaceOrientationPortrait</string>
            <string>UIInterfaceOrientationPortraitUpsideDown</string>
            <string>UIInterfaceOrientationLandscapeLeft</string>
            <string>UIInterfaceOrientationLandscapeRight</string>
        </array>
        <key>NSAppTransportSecurity</key>
        <dict>
            <key>NSAllowsArbitraryLoads</key>
            <true/>
        </dict>
    </dict>
</plist>

【讨论】:

  • 感谢您的回答。因为我从来没有处理过这种 xml 格式,请你给我一个完整的例子吗?
  • 好的,我正在为您提供完整的 xml,以便您可以将其粘贴到您的 plist 中
  • 选择您的 plist。它会显示错误。但右键单击它并选择在 finder 选项中显示。现在右键单击 plist 并选择打开方式选项。现在转到其他选项并选择文本编辑器那里。您的 plist 将在 texteditor 中以 xml 格式打开。现在复制上面的 xml 并删除旧文本并粘贴这个新文本。
  • 所以实际的语法错误是&lt;true/&gt; vs. &lt;true /&gt;,对吧?
  • 不是第一行。这是额外的 en。只需检查密钥 CFBundleDevelopmentRegion
猜你喜欢
  • 2015-03-12
  • 2012-02-21
  • 2011-02-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-09-29
相关资源
最近更新 更多