Error when running pod install on Flutter App

80 views Asked by At

I get this error when i try to build my Flutter App on iOS:

### Error
    ```
    NoMethodError - undefined method `present?' for nil:NilClass
    /Users/User/.rvm/rubies/ruby-2.7.0/lib/ruby/gems/2.7.0/gems/cocoapods-1.13.0/lib/cocoapods/installer/podfile_validator.rb:100:in `validate_conflicting_external_sources!'
    /Users/User/.rvm/rubies/ruby-2.7.0/lib/ruby/gems/2.7.0/gems/cocoapods-1.13.0/lib/cocoapods/installer/podfile_validator.rb:85:in `block in validate_pod_directives'
    /Users/User/.rvm/rubies/ruby-2.7.0/lib/ruby/gems/2.7.0/gems/cocoapods-1.13.0/lib/cocoapods/installer/podfile_validator.rb:84:in `each'
    /Users/User/.rvm/rubies/ruby-2.7.0/lib/ruby/gems/2.7.0/gems/cocoapods-1.13.0/lib/cocoapods/installer/podfile_validator.rb:84:in `validate_pod_directives'
    /Users/User/.rvm/rubies/ruby-2.7.0/lib/ruby/gems/2.7.0/gems/cocoapods-1.13.0/lib/cocoapods/installer/podfile_validator.rb:40:in `validate'
    /Users/User/.rvm/rubies/ruby-2.7.0/lib/ruby/gems/2.7.0/gems/cocoapods-1.13.0/lib/cocoapods/installer/analyzer.rb:225:in `validate_podfile!'
    /Users/User/.rvm/rubies/ruby-2.7.0/lib/ruby/gems/2.7.0/gems/cocoapods-1.13.0/lib/cocoapods/installer/analyzer.rb:104:in `analyze'
    /Users/User/.rvm/rubies/ruby-2.7.0/lib/ruby/gems/2.7.0/gems/cocoapods-1.13.0/lib/cocoapods/installer.rb:422:in `analyze'
    /Users/User/.rvm/rubies/ruby-2.7.0/lib/ruby/gems/2.7.0/gems/cocoapods-1.13.0/lib/cocoapods/installer.rb:244:in `block in resolve_dependencies'
    /Users/User/.rvm/rubies/ruby-2.7.0/lib/ruby/gems/2.7.0/gems/cocoapods-1.13.0/lib/cocoapods/user_interface.rb:64:in `section'
    /Users/User/.rvm/rubies/ruby-2.7.0/lib/ruby/gems/2.7.0/gems/cocoapods-1.13.0/lib/cocoapods/installer.rb:243:in `resolve_dependencies'
    /Users/User/.rvm/rubies/ruby-2.7.0/lib/ruby/gems/2.7.0/gems/cocoapods-1.13.0/lib/cocoapods/installer.rb:162:in `install!'
    /Users/User/.rvm/rubies/ruby-2.7.0/lib/ruby/gems/2.7.0/gems/cocoapods-1.13.0/lib/cocoapods/command/install.rb:52:in `run'
    /Users/User/.rvm/rubies/ruby-2.7.0/lib/ruby/gems/2.7.0/gems/claide-1.1.0/lib/claide/command.rb:334:in `run'
    /Users/User/.rvm/rubies/ruby-2.7.0/lib/ruby/gems/2.7.0/gems/cocoapods-1.13.0/lib/cocoapods/command.rb:52:in `run'
    /Users/User/.rvm/rubies/ruby-2.7.0/lib/ruby/gems/2.7.0/gems/cocoapods-1.13.0/bin/pod:55:in `<top (required)>'
    /Users/User/.rvm/rubies/ruby-2.7.0/bin/pod:25:in `load'
    /Users/User/.rvm/rubies/ruby-2.7.0/bin/pod:25:in `<main>'
    /Users/User/.rvm/gems/ruby-2.7.0/bin/ruby_executable_hooks:22:in `eval'
    /Users/User/.rvm/gems/ruby-2.7.0/bin/ruby_executable_hooks:22:in `<main>'
    ```
    ――― TEMPLATE END ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
    [!] Oh no, an error occurred.
    Search for existing GitHub issues similar to yours:
    https://github.com/CocoaPods/CocoaPods/search?q=undefined+method+%60present%3F%27+for+nil%3ANilClass&type=Issues
    If none exists, create a ticket, with the template displayed above, on:
    https://github.com/CocoaPods/CocoaPods/issues/new
    Be sure to first read the contributing guide for details on how to properly submit a ticket:
    https://github.com/CocoaPods/CocoaPods/blob/master/CONTRIBUTING.md
    Don't forget to anonymize any private data!
    Looking for related issues on cocoapods/cocoapods...
     - pod install fails while trying to call present? on a nil when using activesupport 7.1.0
       https://github.com/CocoaPods/CocoaPods/issues/12089 [closed] [9 comments]
       a week ago
     - Unable to see XCode/SwiftUI Previews within CocoaPods frameworks
       https://github.com/CocoaPods/CocoaPods/issues/9275 [open] [58 comments]
       10 Sep 2023
     - "Error 'DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS, use TOOLCHAIN_DIR instead' in Xcode 15 beta 5"
       https://github.com/CocoaPods/CocoaPods/issues/12012 [closed] [94 comments]
       a week ago
    and 12 more at:
    https://github.com/cocoapods/cocoapods/search?q=undefined%20method%20%60present%3F%27%20for%20nil&type=Issues&utf8=✓
Error running pod install
Error launching application on iPhone 15 Pro Max.

The default Flutter Counter App works good. I have a Macbook with M2 Pro Chip.

I tried: 1. flutter clean flutter pub get 2. sudo arch -x86_64 gem install ffi 3. cd ios arch -x86_64 pod install 4. cd ios pod install --repo-update

1

There are 1 answers

0
Ankit Singh On

Just follow these steps:

# flutter pub cache repair 
# rm -rf Pods  
# rm -rf Podfile.lock  
# rm -rf ~/.pub-cache/hosted/pub.dartlang.org/  
# flutter clean  
# flutter pub get  
# pod repo update  
# flutter build ios