Search code examples
ioscameraflutter

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?


Solution

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