【问题标题】:Info.plist: The data couldn’t be read because it isn’t in the correct formatInfo.plist:由于格式不正确,无法读取数据
【发布时间】:2020-02-02 08:46:47
【问题描述】:

我一直在尝试解决我的 plist 文件中的一个问题,但似乎找不到它。我很确定这是代码中的错误。我正在使用最新版本的 Xcode。我收到以下错误。

error: couldn't parse contents of '/Users/NAME/Downloads/Projects/PROJECT/ios/Runner/Info.plist': The data couldn’t be read because it isn’t in the correct format.

这些是 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>
    <key>CFBundleDevelopmentRegion</key>
    <string>en</string>
    <key>CFBundleExecutable</key>
    <string>$(EXECUTABLE_NAME)</string>
    <key>CFBundleIdentifier</key>
    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>Clone</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>$(FLUTTER_BUILD_NAME)</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleVersion</key>
    <string>$(FLUTTER_BUILD_NUMBER)</string>
    <key>LSRequiresIPhoneOS</key>
    <true />
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UIMainStoryboardFile</key>
    <string>Main</string>
    <key>UISupportedInterfaceOrientations</key>
    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true />
    </dict>
    <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>UIViewControllerBasedStatusBarAppearance</key>
    <false />
</dict>
</plist>

【问题讨论】:

    标签: ios xcode syntax-error plist info.plist


    【解决方案1】:

    语法错误。

    您应该将&lt;key&gt;UISupportedInterfaceOrientations&lt;/key&gt; 移到&lt;array&gt; 的正上方:

    ,,,
    
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
    
    ,,,
    

    原来如此:

    <?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>CFBundleExecutable</key>
        <string>$(EXECUTABLE_NAME)</string>
        <key>CFBundleIdentifier</key>
        <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
        <key>CFBundleInfoDictionaryVersion</key>
        <string>6.0</string>
        <key>CFBundleName</key>
        <string>Clone</string>
        <key>CFBundlePackageType</key>
        <string>APPL</string>
        <key>CFBundleShortVersionString</key>
        <string>$(FLUTTER_BUILD_NAME)</string>
        <key>CFBundleSignature</key>
        <string>????</string>
        <key>CFBundleVersion</key>
        <string>$(FLUTTER_BUILD_NUMBER)</string>
        <key>LSRequiresIPhoneOS</key>
        <true />
        <key>UILaunchStoryboardName</key>
        <string>LaunchScreen</string>
        <key>UIMainStoryboardFile</key>
        <string>Main</string>
        <key>NSAppTransportSecurity</key>
        <dict>
            <key>NSAllowsArbitraryLoads</key>
            <true />
        </dict>
        <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>UIViewControllerBasedStatusBarAppearance</key>
        <false />
    </dict>
    </plist>
    

    【讨论】:

      【解决方案2】:
      UISupportedInterfaceOrientations
      

      键和值未正确添加。您在 NSAppTransportSecurity 上方提到了键 UISupportedInterfaceOrientations 和末尾的值。

      这里是正确的格式

       <?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>CFBundleExecutable</key>
              <string>$(EXECUTABLE_NAME)</string>
              <key>CFBundleIdentifier</key>
              <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
              <key>CFBundleInfoDictionaryVersion</key>
              <string>6.0</string>
              <key>CFBundleName</key>
              <string>Clone</string>
              <key>CFBundlePackageType</key>
              <string>APPL</string>
              <key>CFBundleShortVersionString</key>
              <string>$(FLUTTER_BUILD_NAME)</string>
              <key>CFBundleSignature</key>
              <string>????</string>
              <key>CFBundleVersion</key>
              <string>$(FLUTTER_BUILD_NUMBER)</string>
              <key>LSRequiresIPhoneOS</key>
              <true />
              <key>UILaunchStoryboardName</key>
              <string>LaunchScreen</string>
              <key>UIMainStoryboardFile</key>
              <string>Main</string>
      
              <key>NSAppTransportSecurity</key>
              <dict>
                  <key>NSAllowsArbitraryLoads</key>
                  <true />
              </dict>
      
      
               <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>UIViewControllerBasedStatusBarAppearance</key>
              <false />
          </dict>
      </plist>
      

      【讨论】:

        猜你喜欢
        • 2020-11-20
        • 1970-01-01
        • 2017-06-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-08-29
        • 2016-10-15
        相关资源
        最近更新 更多