iOS Flutter Application Won't Launch; 'fatal error: 'camera/CameraPlugin.h' file not found'?
Solution 1
I had the same issue. I fixed by running pod install
within my project's /ios directory
Solution 2
I would suggest to everyone who still has these issues to do the following steps:
- Open the ios folder
- Double click on the Runner.xcworkspace (NOT Runner.xcodeproj!)
- Pod Install
- Build
The problem is that the cam plugin isn't in the scope of the Runner.xcodeproj.
Solution 3
Did you updated your Info.plist for using the camera plugin? If not,
Add two rows to the ios/Runner/Info.plist:
one with the keyPrivacy - Camera Usage Description
and a usage description.
and one with the key Privacy - Microphone Usage Description
and a usage description.
Or in text format add the key:
<key>NSCameraUsageDescription</key>
<string>Can I use the camera please?</string>
<key>NSMicrophoneUsageDescription</key>
<string>Can I use the mic please?</string>
kiwikodes
Updated on December 09, 2022Comments
-
kiwikodes over 1 year
My Flutter application built on both an Android and iOS device prior. However since implementing the camera plugin, the application will no longer build on the iOS device.
So far I have tried:
- Commenting out the use_frameworks! in the Podfile and tried both pod update and pod clean.
- And adding the permissions into the iOS Info.plist file.
The code I'm running is just a default flutter application with a tab that contains the example code from https://pub.dartlang.org/packages/camera.
Flutter Doctor Output:
Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, v1.0.0, on Mac OS X 10.14.2 18C54, locale en-NZ) [✓] Android toolchain - develop for Android devices (Android SDK 28.0.3) [✓] iOS toolchain - develop for iOS devices (Xcode 10.1) [✓] Android Studio (version 3.3) [✓] VS Code (version 1.31.0) [✓] Connected device (2 available) • No issues found!
Terminal Output:
Launching lib/main.dart on SM G950F in debug mode... Initializing gradle... 1.6s Resolving dependencies... 1.5s Gradle task 'assembleDebug'... registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection) registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection) registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection) registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection) registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection) Gradle task 'assembleDebug'... Done 1.7s Built build/app/outputs/apk/debug/app-debug.apk. Launching lib/main.dart on iPad in debug mode... Automatically signing iOS for device deployment using specified development team in Xcode project: J6K4CJXVB4 Starting Xcode build... ├─Assembling Flutter resources... 1.4s └─Compiling, linking and signing... 1.2s Xcode build done. 3.9s Failed to build iOS app Error output from Xcode build: ↳ ** BUILD FAILED ** Xcode's output: ↳ /Users/Name/Desktop/math_snap/ios/Runner/GeneratedPluginRegistrant.m :6:9: fatal error: 'camera/CameraPlugin.h' file not found #import <camera/CameraPlugin.h> ^~~~~~~~~~~~~~~~~~~~~~~ 1 error generated. Could not build the precompiled application for the device. Error launching application on iPad. 2.5s
As you can see, it launches fine on my Android phone. However trying to run it on iOS does not work. Does anyone know how to fix this?