1、错误标题
NoMethodError - undefined methodsize’ for nil:NilClass`
2、错误内容
――― MARKDOWN TEMPLATE ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――### Command
/usr/local/bin/pod install
### Report* What did you do?* What did you expect to happen?* What happened instead?### Stack
CocoaPods : 1.9.3 Ruby : ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin19] RubyGems : 3.0.3 Host : Mac OS X 10.15.5 (19F101) Xcode : 11.5 (11E608c) Git : git version 2.24.3 (Apple Git-128) Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib Repositories : trunk - CDN - https://cdn.cocoapods.org/
### Plugins
cocoapods-deintegrate : 1.0.4 cocoapods-plugins : 1.0.0 cocoapods-search : 1.0.0 cocoapods-stats : 1.1.0 cocoapods-trunk : 1.5.0 cocoapods-try : 1.2.0
### Podfile```ruby# Uncomment this line to define a global platform for your projectplatform :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_pathreturn [];endgenerated_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 == 2podname = plugin[0].strip()path = plugin[1].strip()podpath = File.expand_path("#{path}", file_abs_path)generated_key_values[podname] = podpathelseputs "Invalid plugin specification: #{line}"endendgenerated_key_valuesendtarget 'Runner' douse_frameworks!use_modular_headers!# Flutter Podcopied_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"endgenerated_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)endunless File.exist?(copied_podspec_path)FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir)endend# 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')endend# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system.install! 'cocoapods', :disable_input_output_paths => truepost_install do |installer|installer.pods_project.targets.each do |target|target.build_configurations.each do |config|config.build_settings['ENABLE_BITCODE'] = 'NO'# You can remove unused permissions here# for more infomation: https://github.com/BaseflowIT/flutter-permission-handler/blob/develop/permission_handler/ios/Classes/PermissionHandlerEnums.h# e.g. when you don't need camera permission, just add 'PERMISSION_CAMERA=0'config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)',## dart: PermissionGroup.calendar'PERMISSION_EVENTS=0',## dart: PermissionGroup.reminders'PERMISSION_REMINDERS=0',## dart: PermissionGroup.contacts'PERMISSION_CONTACTS=0',## dart: PermissionGroup.camera# 'PERMISSION_CAMERA=0',## dart: PermissionGroup.microphone# 'PERMISSION_MICROPHONE=0',## dart: PermissionGroup.speech'PERMISSION_SPEECH_RECOGNIZER=0',## dart: PermissionGroup.photos# 'PERMISSION_PHOTOS=0',## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]'PERMISSION_LOCATION=0',## dart: PermissionGroup.notification# 'PERMISSION_NOTIFICATIONS=0',## dart: PermissionGroup.mediaLibrary'PERMISSION_MEDIA_LIBRARY=0',## dart: PermissionGroup.sensors'PERMISSION_SENSORS=0']endendend
Error
NoMethodError - undefined method `size' for nil:NilClass/Library/Ruby/Gems/2.6.0/gems/ruby-macho-1.4.0/lib/macho/macho_file.rb:455:in `populate_mach_header'/Library/Ruby/Gems/2.6.0/gems/ruby-macho-1.4.0/lib/macho/macho_file.rb:233:in `populate_fields'/Library/Ruby/Gems/2.6.0/gems/ruby-macho-1.4.0/lib/macho/macho_file.rb:55:in `initialize_from_bin'/Library/Ruby/Gems/2.6.0/gems/ruby-macho-1.4.0/lib/macho/macho_file.rb:33:in `new_from_bin'/Library/Ruby/Gems/2.6.0/gems/ruby-macho-1.4.0/lib/macho/fat_file.rb:365:in `block in populate_machos'/Library/Ruby/Gems/2.6.0/gems/ruby-macho-1.4.0/lib/macho/fat_file.rb:364:in `each'/Library/Ruby/Gems/2.6.0/gems/ruby-macho-1.4.0/lib/macho/fat_file.rb:364:in `populate_machos'/Library/Ruby/Gems/2.6.0/gems/ruby-macho-1.4.0/lib/macho/fat_file.rb:156:in `populate_fields'/Library/Ruby/Gems/2.6.0/gems/ruby-macho-1.4.0/lib/macho/fat_file.rb:95:in `initialize'/Library/Ruby/Gems/2.6.0/gems/ruby-macho-1.4.0/lib/macho.rb:31:in `new'/Library/Ruby/Gems/2.6.0/gems/ruby-macho-1.4.0/lib/macho.rb:31:in `open'/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/xcode/linkage_analyzer.rb:16:in `dynamic_binary?'/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/sandbox/file_accessor.rb:171:in `block in vendored_dynamic_frameworks'/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/sandbox/file_accessor.rb:170:in `select'/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/sandbox/file_accessor.rb:170:in `vendored_dynamic_frameworks'/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/sandbox/file_accessor.rb:179:in `vendored_static_frameworks'/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/sandbox/file_accessor.rb:292:in `vendored_static_artifacts'/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer/xcode/target_validator.rb:82:in `each'/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer/xcode/target_validator.rb:82:in `flat_map'/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer/xcode/target_validator.rb:82:in `block (2 levels) in verify_no_static_framework_transitive_dependencies'/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer/xcode/target_validator.rb:74:in `each_key'/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer/xcode/target_validator.rb:74:in `block in verify_no_static_framework_transitive_dependencies'/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer/xcode/target_validator.rb:73:in `each'/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer/xcode/target_validator.rb:73:in `verify_no_static_framework_transitive_dependencies'/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer/xcode/target_validator.rb:38:in `validate!'/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer.rb:590:in `validate_targets'/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer.rb:158:in `install!'/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/command/install.rb:52:in `run'/Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/command.rb:52:in `run'/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/bin/pod:55:in `<top (required)>'/usr/local/bin/pod:23:in `load'/usr/local/bin/pod:23: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+%60size%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…
NoMethodError - undefined method `size’ for nil:NilClass https://github.com/CocoaPods/CocoaPods/issues/8377 [closed] [15 comments] 3 weeks ago
NoMethodError - undefined method `each’ for nil:NilClass https://github.com/CocoaPods/CocoaPods/issues/9239 [closed] [5 comments] 6 weeks ago
NoMethodError - undefined method `size’ for nil:NilClass https://github.com/CocoaPods/CocoaPods/issues/9484 [closed] [9 comments] 14 Apr 2020
and 4 more at: https://github.com/cocoapods/cocoapods/search?q=undefined%20method%20%60size%27%20for%20nil&type=Issues&utf8=✓
<a name="uqEY2"></a>## 3、解决方法```bashflutter cleanrm -Rf ios/Podsrm -Rf ios/.symlinksrm -Rf ios/Flutter/Flutter.frameworkrm -Rf ios/Flutter/Flutter.podspecflutter pub getcd iospod install
