How to write “Podfile” in flutter(ios)

  Kiến thức lập trình

First code I use the Podfile below

platform :ios, '11.0'
  use_frameworks!
  target 'RunnerTests' do
    inherit! :search_paths
    ## dart: PermissionGroup.camera
      'PERMISSION_CAMERA=1'
  end
end

And then ‘pod install’. The result message is ‘Pod installation complete! There are 0 dependencies from the Podfile and 0 pods installed’
Suspicious thing is that 0 pods installed and also when I build in XCode, error is occured

Second code(Podfile) I try below

platform :ios, '11.0'

ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,
}

def flutter_root
  generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
  unless File.exist?(generated_xcode_build_settings_path)
    raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  end

  File.foreach(generated_xcode_build_settings_path) do |line|
    matches = line.match(/FLUTTER_ROOT=(.*)/)
    return matches[1].strip if matches
  end
  raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
  use_frameworks!
  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
      ## dart: PermissionGroup.camera
      'PERMISSION_CAMERA=1'
  end
end

This doesn’t work either.
The error below is occured in Xcode.

Module 'camera_avfoundation' not found
Module {{import package thing..}} not found

This is occured in GeneratedPluginRegistrant file

As a result, what I want to ask is, first Podfile is suspicious because of ‘0 pods installed’ message so is there any problem in my Podfile?
Second is Xcode error message that is occured in GeneratedPluginRegistrant file. I think this error is related to Podfile but I can’t convince that is really related

Thank you for read this question.

  • In MAC OS

It looks like maybe theres a typo in the Podfile.. PERMISSION_CARMERA should be PERMISSION_CAMERA? Im new to coding and I only know swift so forgive me if I am wrong. Maybe that is part of the solution?

New contributor

Xaiv is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

1

LEAVE A COMMENT