skip to Main Content

This is the error I am receiving.
I tried flutter clean and changing the syntax of some lines but im new to dart and flutter so im not really sure. I reinstalled cocoa pods and ruby as well but Im receiving the same error. I also made sure to update ruby to the latest version.

  [!] Invalid `Podfile` file: no implicit conversion of nil into String.
         #  from /Users/(name)/Downloads/Projects/doctor_consultation_app/ios/Podfile:57
         #  -------------------------------------------
         #      unless File.exist?(copied_framework_path)
         >        FileUtils.cp(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir)
         #      end
         #  -------------------------------------------

This is my pod file.

# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

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

def parse_KV_file(file, separator='=')
  file_abs_path = File.expand_path(file)
  if !File.exists? file_abs_path
    return [];
  end
  generated_key_values = {}
  skip_line_start_symbols = ["#", "/"]
  File.foreach(file_abs_path) do |line|
    next if skip_line_start_symbols.any? { |symbol| line =~ /^s*#{symbol}/ }
    plugin = line.split(pattern=separator)
    if plugin.length == 2
      podname = plugin[0].strip()
      path = plugin[1].strip()
      podpath = File.expand_path("#{path}", file_abs_path)
      generated_key_values[podname] = podpath
    else
      puts "Invalid plugin specification: #{line}"
    end
  end
  generated_key_values
end

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  # Flutter Pod

  copied_flutter_dir = File.join(__dir__, 'Flutter')
  copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework')
  copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec')
  unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path)
    # Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
    # That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.
    # CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.

    generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig')
    unless File.exist?(generated_xcode_build_settings_path)
      raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first"
    end
    generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path)
    cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR'];

    unless File.exist?(copied_framework_path)
      FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir)
    end
    unless File.exist?(copied_podspec_path)
      FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir)
    end
  end

  # Keep pod path relative so it can be checked into Podfile.lock.
  pod 'Flutter', :path => 'Flutter'

  # Plugin Pods

  # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
  # referring to absolute paths on developers' machines.
  system('rm -rf .symlinks')
  system('mkdir -p .symlinks/plugins')
  plugin_pods = parse_KV_file('../.flutter-plugins')
  plugin_pods.each do |name, path|
    symlink = File.join('.symlinks', 'plugins', name)
    File.symlink(path, symlink)
    pod name, :path => File.join(symlink, 'ios')
  end
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['ENABLE_BITCODE'] = 'NO'
    end
  end
end

8

Answers


  1. I have same problem when I update my mac –> BigSur and use Ruby .

    And I solve it by rm -rf ios and flutter create .

    Then fix some file changes in new ios

    Warning!!!

    if use this on your existing app, it will deleted your iOS folder, but You may have some custom settings in it. So you should add your commit into the new file!!!

    Login or Signup to reply.
  2. I solve it just replace: copied_flutter_dir = File.join(__dir__, 'Flutter') to copied_flutter_dir = File.join('.', 'Flutter').

    Login or Signup to reply.
  3. I was in channel beta and I solved like this. flutter channel stable and flutter upgrade

    Login or Signup to reply.
  4. Just sharing my experience with this type of issue, it looks like its basically a versioning issue of pods. I’ve worked in several hybrid platforms, and it turns out all of the platforms are struggling when comes to build for iOS. Here’s how I resolved it:

    • I’ve checked my flutter channel whether it’s beta or stable, I found it was beta so I switched into the stable channel. commands are flutter channel to see the active channel, then switch to stable if its selected beta by running the command flutter channel stable
    • remove all generated pod/related files for a fresh build. do the following:
      • run rm -rf ios/Pods
      • run rm -rf ios/.symlinks
      • run rm -rf ios/Flutter/Flutter.framework
    • run flutter clean
    • run cd ios in case you’re not in the ios folder.
    • run pod cache clean --all
    • run pod repo update
    • run pod install
    • uncomment platform :ios, 'X.0' from Podfile inside ios folder, and replace X with the current version you’re woking.
    • run flutter build ios better use --verbose to see if any other issues are there.

    Hope this will help if anyone stuck at the same problem.
    thanks to these guys.

    https://stackoverflow.com/a/64318163/3502024

    https://stackoverflow.com/a/65539806/3502024

    Login or Signup to reply.
  5. The Pod file can change depending on the channel you are using.
    Try to update flutter

    flutter channel stable
    flutter upgrade
    

    Delete your pod file and the Pods folder then rebuild your ios project

    flutter build ios
    
    Login or Signup to reply.
  6. I had to delete the podfile and add it back, then add my extensions back in. Now it seems to be working again. Most of the file got stripped, for example the new file has no parse_KV_file method.

    Login or Signup to reply.
  7. I got this error when I updated my flutter sdk to the new flutter 2.0, but my project was created with older version of flutter sdk (1.22).

    Fixed It by deleting the Podfile and Podfile.lock in ios folder and then run:

    flutter run
    

    or

    flutter build ios
    

    That way flutter will generate the new Podfile for flutter 2.0

    Login or Signup to reply.
  8. pls make sure to remove to .dart_tool folder from the root of the project,

    Then inside the ios folder, try flutter clean and flutter build ios

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search