32

This is the error I am receiving.

I tried flutter clean and changing the syntax of some lines, but I’m new to Dart and Flutter, so im not really sure. I reinstalled CocoaPods and the Ruby interpreter as well, but I’m receiving the same error. I also made sure to update the Ruby interpreter 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
4
  • What about clearing all cache? Commented Dec 31, 2020 at 9:55
  • In addition, do you change the podfile? Commented Dec 31, 2020 at 9:55
  • I am facing the same any solution please ? Commented Mar 6, 2021 at 20:38
  • same issue here, any solution? Commented Mar 10, 2021 at 8:58

8 Answers 8

48

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).

I fixed it by deleting the Podfile and Podfile.lock in the ios folder and then ran:

flutter run

or

flutter build ios

That way, Flutter will generate the new Podfile for Flutter 2.0.

Sign up to request clarification or add additional context in comments.

1 Comment

You may need to uncomment the "platform :ios, '9.0'" to build successfully.
9

I have same problem when I update my Mac → macOS v11 (Big Sur) 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 delete your iOS folder, but you may have some custom settings in it. So you should add your commit into the new file!!!

4 Comments

Don't use this on your existing app, This deleted my iOS folder and flutter create command will create a new project. Thankfully I use git and could reset to my commit.
You should add "Warning" test in your solution for existing applications
You'd need to set the project path on the script, you can also specify the paltform that you'll create i.e. flutter create --platforms=ios [PROJECT_PATH]. Replace [PROJECT_PATH] with the actual path of the Flutter project.
flutter create . or flutter create? Is the full stop included or not?
2

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.

Comments

2

I was in channel beta and I solved like this:

flutter channel stable

and

flutter upgrade

Comments

2

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

Comments

0

I solve it just by replacing: copied_flutter_dir = File.join(__dir__, 'Flutter') with copied_flutter_dir = File.join('.', 'Flutter').

Comments

0

Please 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.

Comments

0

I am just sharing my experience with this type of issue. It looks like it’s basically a versioning issue of pods. I've worked on 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.

Flutter pod file issues

Flutter error on pod install: CocoaPods could not find compatible versions for pod "Firebase/CoreOnly"

1 Comment

Getting this mess, too. I've done NOTHING to this code tree in a couple of months, and now this. I swear, this platform just gets more and more fragile every day. I had to basically do ALL of this crap, all the suggestions, to get it to work and I'm still getting new runtime errors that were previously gone (the threading thing that people keep reporting). All I wanted to do was install it on another phone I had here. No code or dependency changes. Worked fine last time I was in here. I can't keep supporting this platform like this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.