Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Flutter Application Won't Launch; 'fatal error: 'camera/CameraPlugin.h' file not found'?

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?

like image 602
kiwikodes Avatar asked Feb 10 '19 00:02

kiwikodes


4 Answers

I would suggest to everyone who still has these issues to do the following steps:

  1. Open the ios folder
  2. Double click on the Runner.xcworkspace (NOT Runner.xcodeproj!)
  3. Pod Install
  4. Build

The problem is that the cam plugin isn't in the scope of the Runner.xcodeproj.

like image 197
VasilKanev Avatar answered Nov 14 '22 22:11

VasilKanev


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 Descriptionand a usage description. and one with the key Privacy - Microphone Usage Descriptionand 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>

like image 21
krishnakumarcn Avatar answered Nov 14 '22 20:11

krishnakumarcn


I had the same issue. I fixed by running pod install within my project's /ios directory

like image 34
Simon Rubin Avatar answered Nov 14 '22 21:11

Simon Rubin


delete the podfile then flutter run again,the podfile will be auto generated again. then build successful !!!

like image 36
user10005018 Avatar answered Nov 14 '22 20:11

user10005018