How can I resolve the camera_avfoundation not found error when building a Flutter camera app with Xcode?

824 Views Asked by At
When I build a camera app made with Flutter in Xcode, it keeps saying that camera_avfoundation cannot be found. So, as shown below, I installed the dependency in pubspec.yaml and performed flutter pub get, and when I applied the same dependency to the podfile and ran pod install, the following error occurred, and the error that camera_avfoundation was not found continued to appear.. How should I set it up? Can I successfully build a camera app?

[pod install error]

Analyzing dependencies
[!] Unable to find a specification for `camera (~> 0.10.5)`

You have either:
  * out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`.
  * mistyped the name or version.
  * not added the source repo that hosts the Podspec to your Podfile.

[pubspec.yaml]

name: brix
description: A new Flutter project.

publish_to: 'none'


version: 1.0.0+1

environment:
   sdk: '>=3.0.0 <4.0.0'


dependencies:
   flutter:
     sdk: flutter
   camera : ^0.10.5
   path_provider: ^2.0.15
   gallery_saver: ^2.3.2
   logger: ^1.3.0
   camera_avfoundation: ^0.9.13+1


dev_dependencies:
   flutter_test:
     sdk: flutter

   flutter_lints: ^2.0.0

flutter:
   assets:
     - assets/background_login.jpeg
     - assets/background.jpeg

     - assets/naver_login.jpeg
     - assets/kakao_login.jpeg

     - assets/camera_icon.jpeg
     - assets/shopping_icon.jpeg
     - assets/event_icon.jpeg

     - assets/board_icon.jpeg
     - assets/question_icon.jpeg
     - assets/settings_icon.jpeg

[Podfile]

platform :ios, '11.0'

source 'https://cdn.cocoapods.org/'

target 'Runner' do
   # Comment the next line if you don't want to use dynamic frameworks
   use_frameworks!

   # Pods for Runners
   pod 'camera', '~> 0.10.5'
   pod 'path_provider', '~> 2.0.15'
   pod 'gallery_saver', '~> 2.3.2'
   pod 'logger', '~> 1.3.0'
   pod 'camera_avfoundation', '~> 0.9.13+1'

   target 'RunnerTests' do
     inherit! :search_paths
     # Pods for testing
   end
end

I wonder if there is no syntax to import camera_avfoundation from camera.dart, so I can't find it when building the package,

import 'package:camera_avfoundation/camera_avfoundation.dart';

After adding the syntax, it was built, but the build also failed with the same error.

flutter clean rm-Podfile rm -rf Podfile.lock pod install pod repo update And I also initialized it with a clean build folder in Xcode.

1

There are 1 best solutions below

0
On

I had this error multiple times. Always happened after upgrading camera package.

First, make sure platform: iOS version in pod file matches with deployment info in Xcode

What worked for me was this:

  1. In Xcode-> Product-> Clean build folder
  2. pod repo update from ios direc
  3. pod install
  4. Close Xcode, and restart.

This only happened on Xcode, running in Android Studio worked fine.