Reputation: 367
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
Upvotes: 32
Views: 23714
Reputation: 940
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:
flutter channel
to see the active channel, then switch to stable if its selected beta by running the command flutter channel stable
rm -rf ios/Pods
rm -rf ios/.symlinks
rm -rf ios/Flutter/Flutter.framework
flutter clean
cd ios
in case you're not in the ios folder.pod cache clean --all
pod repo update
pod install
platform :ios, 'X.0'
from Podfile inside ios folder, and replace X with the current version you're woking.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.
Upvotes: 0
Reputation: 1
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
.
Upvotes: 0
Reputation: 1565
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.
Upvotes: 48
Reputation: 713
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
Upvotes: 2
Reputation: 21
I was in channel beta and I solved like this:
flutter channel stable
and
flutter upgrade
Upvotes: 2
Reputation: 304
I solve it just by replacing: copied_flutter_dir = File.join(__dir__, 'Flutter')
with copied_flutter_dir = File.join('.', 'Flutter')
.
Upvotes: 0
Reputation: 516
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.
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!!!
Upvotes: 9
Reputation: 21
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.
Upvotes: 2