iosflutterxcodemacospodfile

How to write "Podfile" in flutter(ios)


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.


Solution

  • Finally I solved this problem by referencing other question/answer -> Flutter module not found in Xcode

    Below is the method which is useful!

    First

    1. Delete Podfile
    2. flutter clean
    3. flutter pub get
    4. flutter build ios

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

    Third, if you run the program through Xcode, you have to opened the Runner.xcworkspace file in XCode, not Runner.xcodeproj file