简体   繁体   English

一个Flutter项目building with Xcode for iOS打开相机错误和一些警告

[英]Open camera error and a few warnings on a Flutter project building with Xcode for iOS

I wanted to test the app for iOS and I installed Xcode .我想测试iOS的应用程序,我安装了Xcode

The problem is that I have a few buildtime warnings and 2 bugs only on iOS .问题是我在iOS上有一些构建时警告和 2 个错误。 First, the camera is not opening and I'm receiving this error without any stack trace as you see in the picture below.首先,相机没有打开,我收到了这个没有任何堆栈跟踪的错误,如下图所示。 And the second problem is that images added in shared preferences are not displaying when I rebuild the project.第二个问题是,当我重建项目时,在共享首选项中添加的图像没有显示。

I see that some functions are not compatible with the deployment target, 12.0 in my case.我看到某些功能与部署目标不兼容,在我的例子中是12.0 I don't know Swift at all.我根本不知道Swift I added in ios/Runner/Info.plist these settings:我在 ios/Runner/Info.plist 中添加了这些设置:

<key>NSCameraUsageDescription</key>
<string>Allow access to camera to capture photos</string>
<key>NSMicrophoneUsageDescription</key>
<string>Allow access to microphone</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Allow access to photo library</string>

The dependencies are setted to any to match the last stable version.依赖项设置为 any 以匹配上一个稳定版本。

dependencies:
  flutter:
    sdk: flutter
  image_picker: any
  shared_preferences: any
  image_collage_widget: any
  screenshot: any
  persistent_bottom_nav_bar: any
  flutter_staggered_grid_view: any
  image_gallery_saver: any
  sqflite: any
  path: any
  dropdown_button2: any
  rflutter_alert: any
  animated_widgets: any
  flutter_launcher_icons: any

So, why my camera is not opening on iOS , how to get rid of these warnings and why my shared preferences images are not rendered on iOS ?那么,为什么我的相机没有在iOS上打开,如何消除这些警告以及为什么我的共享首选项图像没有在iOS上呈现?

Edit : If I test on real iOS mobile device, the camera is working...编辑:如果我在真实的 iOS 移动设备上进行测试,相机正在工作......

在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

Warnings: These are just warnings, you can ignore them. Warnings:这些只是警告,您可以忽略它们。 Project will run.项目将运行。 ( You can work on those warnings) (你可以处理这些警告)

Camera issue: is because simulator doesn't have camera. Camera issue:是因为模拟器没有相机。

I solved the problems:我解决了问题:

  • the images are now rendering from shared preferences, the problem was that I was saving them as string paths, instead of saving them as base64strings .图像现在从共享首选项呈现,问题是我将它们保存为字符串路径,而不是将它们保存为base64strings

  • the iOS simulator doesn't have a camera as @Ujjawal Maurya said in an answer.正如@Ujjawal Maurya 在回答中所说,iOS 模拟器没有摄像头。

The warnings are still there, but I can ignore them as the app is still running well.警告仍然存在,但我可以忽略它们,因为该应用程序仍在正常运行。 It's a good practice to change the deprecated functions, but I don't know Swift at all.更改已弃用的功能是一个好习惯,但我根本不知道 Swift。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 iOS:在Pod中使用Segment-Firebase时构建Xcode Project时出错 - iOS: Error while building Xcode Project when using Segment-Firebase in pods Flutter没有构建iOS应用程序,这是一个迅速的错误吗? - Flutter not building iOS application, is it a swift error? 使用版本 Xcode 11.4 构建 Xcode 项目时反复出错 - Repeated Error in Building the Xcode Project with Version Xcode 11.4 Xcode 错误:为 iOS 模拟器构建,但在为 Z1BDF605991920DBF8508204C4EBZ 模拟器构建的 object 文件中链接 - Xcode error: building for iOS Simulator, but linking in object file built for iOS XCode 还是 Visual Studio? 使用 iPhone 摄像头构建人体运动检测 iOS 应用程序 - XCode or Visual Studio ? Building Human Motion detection iOS app using iPhone camera 在IOS应用中构建相机时出错 - Errors building a camera in an IOS app 无法打开iOS相机 - Not able to Open a Camera for iOS Xcode 在 flutter 项目中编写 ios 本机 swift 代码时给出错误类型“FlutterViewController”的值没有成员“binaryMessenger” - Xcode giving error Value of type 'FlutterViewController' has no member 'binaryMessenger' when writing ios native swift code in flutter project AirPrint (UIPrintInteractionController) 使用 iOS 9、swift 2、XCode 7 打印警告 - AirPrint (UIPrintInteractionController) print warnings with iOS 9, swift 2, XCode 7 Flutter ios 未内置在 xcode - Flutter ios not build in xcode
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM