Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invalid `Podfile` file: undefined method `exists?' for File:Class

Tags:

cocoapods

I am facing an issue with Podfile as below while installing pod in Xcode project.

Invalid Podfile file: undefined method `exists?' for File:Class

I did try to update pod version with brew upgrade cocoapods and also followed below link:

https://dev.to/retyui/fix-a-pod-install-error-undefined-method-exist-for-fileclass-react-native-24ke

But still no fix.

Please guide me what am I doing wrong here.

Below is my Podfile:

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


flutter_application_path = '../bmi_flutter'
    
load File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')

target 'MixedNativeApp' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!
  install_all_flutter_pods(flutter_application_path)
  # Pods for MixedNativeApp

  target 'MixedNativeAppTests' do
    inherit! :search_paths
    # Pods for testing
  end

  target 'MixedNativeAppUITests' do
    # Pods for testing
  end

end
like image 499
Gagan_iOS Avatar asked Sep 11 '25 13:09

Gagan_iOS


2 Answers

Downgrade cocoapods version can fix it. But if you use XCode 14.3++ and want to archive app, you will get issues.

I tried this way and it worked, open this file in your flutter sdk:

flutter/packages/flutter_tools/bin/pod_helper.rb

Then replace

return [] unless File.exists? file_path

to

return [] unless File.exist? file_path
like image 179
tdt kien Avatar answered Sep 15 '25 23:09

tdt kien


Here is my solution for above problem (Posting if it could be helpful for devs in same situation)

gem cleanup
brew uninstall cocoapods
sudo gem uninstall cocoapods
sudo gem install cocoapods -v 1.10.0 -n /usr/local/bin   ***`add cocoapod version u want to install`***
sudo gem install cocoapods-user-defined-build-types
pod install --repo-update
like image 39
Gagan_iOS Avatar answered Sep 15 '25 22:09

Gagan_iOS