NoMethodError - undefined method

2020-04-16  本文已影响0人  chic_wx

最近在开发Flutter项目时,遇到莫名其妙的错误:

NoMethodError - undefined method `size' for nil:NilClass
/opt/local/lib/ruby2.2/gems/2.2.0/gems/ruby-macho-1.2.0/lib/macho/macho_file.rb:420:in `populate_mach_header'
/opt/local/lib/ruby2.2/gems/2.2.0/gems/ruby-macho-1.2.0/lib/macho/macho_file.rb:234:in `populate_fields'
/opt/local/lib/ruby2.2/gems/2.2.0/gems/ruby-macho-1.2.0/lib/macho/macho_file.rb:55:in `initialize_from_bin'
/opt/local/lib/ruby2.2/gems/2.2.0/gems/ruby-macho-1.2.0/lib/macho/macho_file.rb:33:in `new_from_bin'
/opt/local/lib/ruby2.2/gems/2.2.0/gems/ruby-macho-1.2.0/lib/macho/fat_file.rb:321:in `block in populate_machos'
/opt/local/lib/ruby2.2/gems/2.2.0/gems/ruby-macho-1.2.0/lib/macho/fat_file.rb:320:in `each'
/opt/local/lib/ruby2.2/gems/2.2.0/gems/ruby-macho-1.2.0/lib/macho/fat_file.rb:320:in `populate_machos'
/opt/local/lib/ruby2.2/gems/2.2.0/gems/ruby-macho-1.2.0/lib/macho/fat_file.rb:124:in `populate_fields'
/opt/local/lib/ruby2.2/gems/2.2.0/gems/ruby-macho-1.2.0/lib/macho/fat_file.rb:63:in `initialize'
/opt/local/lib/ruby2.2/gems/2.2.0/gems/ruby-macho-1.2.0/lib/macho.rb:31:in `new'
/opt/local/lib/ruby2.2/gems/2.2.0/gems/ruby-macho-1.2.0/lib/macho.rb:31:in `open'
/opt/local/lib/ruby2.2/gems/2.2.0/gems/cocoapods-1.5.3/lib/cocoapods/sandbox/file_accessor.rb:431:in `dynamic_binary?'
/opt/local/lib/ruby2.2/gems/2.2.0/gems/cocoapods-1.5.3/lib/cocoapods/sandbox/file_accessor.rb:164:in `block in vendored_dynamic_frameworks'
/opt/local/lib/ruby2.2/gems/2.2.0/gems/cocoapods-1.5.3/lib/cocoapods/sandbox/file_accessor.rb:163:in `select'
/opt/local/lib/ruby2.2/gems/2.2.0/gems/cocoapods-1.5.3/lib/cocoapods/sandbox/file_accessor.rb:163:in `vendored_dynamic_frameworks'
/opt/local/lib/ruby2.2/gems/2.2.0/gems/cocoapods-1.5.3/lib/cocoapods/sandbox/file_accessor.rb:172:in `vendored_static_frameworks'
/opt/local/lib/ruby2.2/gems/2.2.0/gems/cocoapods-1.5.3/lib/cocoapods/generator/xcconfig/xcconfig_helper.rb:122:in `add_static_dependency_build_settings'
/opt/local/lib/ruby2.2/gems/2.2.0/gems/cocoapods-1.5.3/lib/cocoapods/generator/xcconfig/xcconfig_helper.rb:89:in `block in add_settings_for_file_accessors_of_target'
/opt/local/lib/ruby2.2/gems/2.2.0/gems/cocoapods-1.5.3/lib/cocoapods/generator/xcconfig/xcconfig_helper.rb:86:in `each'
/opt/local/lib/ruby2.2/gems/2.2.0/gems/cocoapods-1.5.3/lib/cocoapods/generator/xcconfig/xcconfig_helper.rb:86:in `add_settings_for_file_accessors_of_target'
/opt/local/lib/ruby2.2/gems/2.2.0/gems/cocoapods-1.5.3/lib/cocoapods/generator/xcconfig/xcconfig_helper.rb:424:in `block in generate_vendored_build_settings'
/opt/local/lib/ruby2.2/gems/2.2.0/gems/cocoapods-1.5.3/lib/cocoapods/generator/xcconfig/xcconfig_helper.rb:422:in `each'
/opt/local/lib/ruby2.2/gems/2.2.0/gems/cocoapods-1.5.3/lib/cocoapods/generator/xcconfig/xcconfig_helper.rb:422:in `generate_vendored_build_settings'
/opt/local/lib/ruby2.2/gems/2.2.0/gems/cocoapods-1.5.3/lib/cocoapods/generator/xcconfig/aggregate_xcconfig.rb:79:in `generate'
/opt/local/lib/ruby2.2/gems/2.2.0/gems/cocoapods-1.5.3/lib/cocoapods/generator/xcconfig/aggregate_xcconfig.rb:39:in `save_as'
/opt/local/lib/ruby2.2/gems/2.2.0/gems/cocoapods-1.5.3/lib/cocoapods/installer/xcode/pods_project_generator/target_installer.rb:107:in `update_changed_file'
/opt/local/lib/ruby2.2/gems/2.2.0/gems/cocoapods-1.5.3/lib/cocoapods/installer/xcode/pods_project_generator/aggregate_target_installer.rb:96:in `block in create_xcconfig_file'
/opt/local/lib/ruby2.2/gems/2.2.0/gems/cocoapods-1.5.3/lib/cocoapods/installer/xcode/pods_project_generator/aggregate_target_installer.rb:93:in `each'
/opt/local/lib/ruby2.2/gems/2.2.0/gems/cocoapods-1.5.3/lib/cocoapods/installer/xcode/pods_project_generator/aggregate_target_installer.rb:93:in `create_xcconfig_file'
/opt/local/lib/ruby2.2/gems/2.2.0/gems/cocoapods-1.5.3/lib/cocoapods/installer/xcode/pods_project_generator/aggregate_target_installer.rb:18:in `block in install!'
/opt/local/lib/ruby2.2/gems/2.2.0/gems/cocoapods-1.5.3/lib/cocoapods/user_interface.rb:142:in `message'
/opt/local/lib/ruby2.2/gems/2.2.0/gems/cocoapods-1.5.3/lib/cocoapods/installer/xcode/pods_project_generator/aggregate_target_installer.rb:14:in `install!'
/opt/local/lib/ruby2.2/gems/2.2.0/gems/cocoapods-1.5.3/lib/cocoapods/installer/xcode/pods_project_generator.rb:181:in `block (2 levels) in install_libraries'
/opt/local/lib/ruby2.2/gems/2.2.0/gems/cocoapods-1.5.3/lib/cocoapods/installer/xcode/pods_project_generator.rb:179:in `each'
/opt/local/lib/ruby2.2/gems/2.2.0/gems/cocoapods-1.5.3/lib/cocoapods/installer/xcode/pods_project_generator.rb:179:in `block in install_libraries'
/opt/local/lib/ruby2.2/gems/2.2.0/gems/cocoapods-1.5.3/lib/cocoapods/user_interface.rb:142:in `message'
/opt/local/lib/ruby2.2/gems/2.2.0/gems/cocoapods-1.5.3/lib/cocoapods/installer/xcode/pods_project_generator.rb:167:in `install_libraries'
/opt/local/lib/ruby2.2/gems/2.2.0/gems/cocoapods-1.5.3/lib/cocoapods/installer/xcode/pods_project_generator.rb:65:in `generate!'
/opt/local/lib/ruby2.2/gems/2.2.0/gems/cocoapods-1.5.3/lib/cocoapods/installer.rb:184:in `block in generate_pods_project'
/opt/local/lib/ruby2.2/gems/2.2.0/gems/cocoapods-1.5.3/lib/cocoapods/user_interface.rb:64:in `section'
/opt/local/lib/ruby2.2/gems/2.2.0/gems/cocoapods-1.5.3/lib/cocoapods/installer.rb:183:in `generate_pods_project'
/opt/local/lib/ruby2.2/gems/2.2.0/gems/cocoapods-1.5.3/lib/cocoapods/installer.rb:119:in `install!'
/opt/local/lib/ruby2.2/gems/2.2.0/gems/cocoapods-1.5.3/lib/cocoapods/command/install.rb:41:in `run'
/opt/local/lib/ruby2.2/gems/2.2.0/gems/claide-1.0.2/lib/claide/command.rb:334:in `run'
/opt/local/lib/ruby2.2/gems/2.2.0/gems/cocoapods-1.5.3/lib/cocoapods/command.rb:52:in `run'
/opt/local/lib/ruby2.2/gems/2.2.0/gems/cocoapods-1.5.3/bin/pod:55:in `<top (required)>'
/opt/local/bin/pod:22:in `load'
/opt/local/bin/pod:22:in `<main>'

解决方法:最好将flutter和Cocoapods升级到最新版本

flutter clean
rm -Rf ios/Pods
rm -Rf ios/.symlinks
rm -Rf ios/Flutter/Flutter.framework
rm -Rf ios/Flutter/Flutter.podspec

上一篇下一篇

猜你喜欢

热点阅读