Flutter IOS 应用程序不会以 image_picker 开头:^0.6.3+4

Flutter IOS app won't start with image_picker: ^0.6.3+4

当我尝试在 IOS 边。 Android 方面一切正常。

我在 info.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>
    <!-- for Image Picker -->  
    <key>NSPhotoLibraryUsageDescription</key>
    <String>This app requires access to the photo library</String>
    <key>NSCameraUsageDescription</key>
    <string>This app requires access to the camera</string>
    <key>NSMicrophoneUsageDescription</key>
    <string>This app does not require access to the microphone</string>
    
    <key>CFBundleDevelopmentRegion</key>
    <string>$(DEVELOPMENT_LANGUAGE)</string>

当我从 info.plist 中删除上述属性时,应用程序工作正常,直到我使用相机。但是,如果我将属性添加到 info.plist 中,应用程序将无法启动。

我在尝试 运行 IOS 应用程序时出现以下错误。

/Users/abcshah/Library/Developer/Xcode/DerivedData/Runner-btwtkgmqdpzzlbcimpfmyibbmiua/Build/Intermediates.noindex/Runner.build/Debug-iphonesimulator/Runner.build/assetcatalog_generated_info.plist

error: unable to read property list from file: /Volumes/abc/projects/new/iconspro/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: Planning build

note: Constructing build description

Could not build the application for the simulator. Error launching application on iPhone 8 Plus.

听起来您需要在传统模式下构建。在 xcode 中加载您的项目并转到:

File -> Workspace Settings -> Build System,并更改为遗留构建系统

清理然后重建,这应该适合你

看来我的第一个猜测并没有完全成立。我也在我的项目中使用 image_picker 插件,并且能够通过从 string

更改标签来产生一堆错误
<key>NSPhotoLibraryUsageDescription</key> 
<string>This app requires access to the camera.</string>

字符串

<key>NSPhotoLibraryUsageDescription</key> 
<String>This app requires access to the camera.</String>

因此我建议您注意标签的大小写。
确保所有 <string> 标签都是小写的。