[英]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.