无法从文件中读取属性列表,当我在应用程序中使用 Mapbox sdk 时出现 Info.plist 问题

问题描述 投票:0回答:5

我在我的一个 Flutter 应用程序中遇到了问题。我正在使用 MapBox-SDK 插件,但是当我在 IOS 上测试该应用程序时,它要求我将 Mapbox-sdk 更新到某个版本(我使用 pop install 命令执行此操作)。现在,在一切之后,我在 info.plist 文件中面临新的错误。我忘记备份旧的 info.plist 文件。 无论如何,新的 info.plist 是:

<plist version="1.0">
<dict>
<string>YES</string>
<key>io.flutter.embedded_views_preview</key>
<true/>
<key>MGLMapboxAccessToken</key>
<string>Mapbox-key-not-visible</string>
<true/>
<key>NSLocationWhenInUseUsageDescription</key>
<key>NSLocationAlwaysUsageDescription</key>
<key>NSPhotoLibraryUsageDescription</key>
<key>NSCameraUsageDescription</key>
<key>NSMicrophoneUsageDescription</key>
<string>This app needs access to location when open.</string>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</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>project1</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>
<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

我在构建应用程序时遇到的错误是:

错误:

Users/apple/flutter-practice/Project-Casky/casky/ios/Runner/Info.plist: Property List       error: Found non-key inside <dict> at line 10 / JSON error: JSON text did not start with array or object and option to allow fragments not set.
Xcode build done.                                           24.2s
Failed to build iOS app
Error output from Xcode build:
↳
** BUILD FAILED **
Xcode's output:
↳
error: unable to read property list from file: /Users/apple/flutter-practice/Project-  Casky/casky/ios/Runner/Info.plist: The operation couldn’t be completed.  (XCBUtil.PropertyListConversionError error 1.) (in target 'Runner' from project 'Runner')
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Constructing build description
warning: Mapping architecture armv7 to i386. Ensure that this target's Architectures and Valid Architectures build settings are configured correctly for the iOS Simulator  platform. (in target 'image_picker' from project 'Pods')
warning: Mapping architecture arm64 to x86_64. Ensure that this target's Architectures and Valid Architectures build settings are configured correctly for the iOS  Simulator platform. (in target 'image_picker' from project 'Pods')
warning: Capabilities for Signing & Capabilities may not function correctly because its entitlements use a placeholder team ID. To resolve this, select a development team in  the Runner editor. (in target 'Runner' from project 'Runner')
Could not build the application for the simulator.
Error launching application on iPhone 11 Pro Max.
Exited (sigterm)

各位我找不到解决方案。请尽可能帮助我。预先感谢。

ios flutter dart error-handling info.plist
5个回答
6
投票

错误

error: unable to read property list from file: Info.plist
通常是由于plist文件中缺少配置引起的。正如前面在评论中提到的,您需要在
NSLocationWhenInUseUsageDescription
上设置一个值。更多详细信息请参阅包的文档

<key>NSLocationWhenInUseUsageDescription</key>
<string>[Your explanation here]</string>

3
投票

就我而言,这是因为 Info.plist 文件格式不正确。它与 XML 格式无关,因为当我尝试查找该文件是否根据 XML 规则正确格式化时,没问题,但是当我尝试将 .plist 文件作为属性列表打开时,我意识到 Xcode 无法没读过,所以我使用属性列表实用程序添加了我的密钥,而不是“代码视图”。


0
投票

我在新导入的 Flutter 项目中也遇到了同样的问题。经过一些调试后,问题似乎是由损坏的 GoogleService-Info.plist 文件引起的!不知道为什么以及如何损坏,因为我新导入了现有项目。

要解决此问题,您可以按照以下步骤操作;

在 XCode 中打开您的项目 删除现有的 GoogleService-Info.plist 文件 从 Firebase 下载原始版本 然后重新导入/重新复制该文件到您的项目中 完成后,运行 flutter clean,然后尝试在 iOS Simulator 中运行它

这对我有用,希望它也能解决您的问题。


0
投票

我通过在每个

<string/>
之后添加
<key>...</key>
解决了这个问题,如下所示:

<key>NSPhotoLibraryUsageDescription</key>
<string /> 

<key>NSCameraUsageDescription</key>
<string /> 

<key>NSMicrophoneUsageDescription</key>
<string /> 

0
投票

如果添加没有任何值的键,就会导致此问题。

第1步:

作为源代码打开

enter image description here

第2步:

检查是否有类似这样的没有任何值的键。删除此键并保存

<key></key>

步骤3:

右键单击 info plist 文件 -> 打开为 属性列表

© www.soinside.com 2019 - 2024. All rights reserved.