1、错误标题

NoMethodError - undefined methodsize’ for nil:NilClass`

2、错误内容

  1. ――― MARKDOWN TEMPLATE ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
  2. ### Command

/usr/local/bin/pod install

  1. ### Report
  2. * What did you do?
  3. * What did you expect to happen?
  4. * What happened instead?
  5. ### 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/

  1. ### 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

  1. ### Podfile
  2. ```ruby
  3. # Uncomment this line to define a global platform for your project
  4. platform :ios, '9.0'
  5. # CocoaPods analytics sends network stats synchronously affecting flutter build latency.
  6. ENV['COCOAPODS_DISABLE_STATS'] = 'true'
  7. project 'Runner', {
  8. 'Debug' => :debug,
  9. 'Profile' => :release,
  10. 'Release' => :release,
  11. }
  12. def parse_KV_file(file, separator='=')
  13. file_abs_path = File.expand_path(file)
  14. if !File.exists? file_abs_path
  15. return [];
  16. end
  17. generated_key_values = {}
  18. skip_line_start_symbols = ["#", "/"]
  19. File.foreach(file_abs_path) do |line|
  20. next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
  21. plugin = line.split(pattern=separator)
  22. if plugin.length == 2
  23. podname = plugin[0].strip()
  24. path = plugin[1].strip()
  25. podpath = File.expand_path("#{path}", file_abs_path)
  26. generated_key_values[podname] = podpath
  27. else
  28. puts "Invalid plugin specification: #{line}"
  29. end
  30. end
  31. generated_key_values
  32. end
  33. target 'Runner' do
  34. use_frameworks!
  35. use_modular_headers!
  36. # Flutter Pod
  37. copied_flutter_dir = File.join(__dir__, 'Flutter')
  38. copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework')
  39. copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec')
  40. unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path)
  41. # Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
  42. # That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.
  43. # CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.
  44. generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig')
  45. unless File.exist?(generated_xcode_build_settings_path)
  46. raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  47. end
  48. generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path)
  49. cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR'];
  50. unless File.exist?(copied_framework_path)
  51. FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir)
  52. end
  53. unless File.exist?(copied_podspec_path)
  54. FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir)
  55. end
  56. end
  57. # Keep pod path relative so it can be checked into Podfile.lock.
  58. pod 'Flutter', :path => 'Flutter'
  59. # Plugin Pods
  60. # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
  61. # referring to absolute paths on developers' machines.
  62. system('rm -rf .symlinks')
  63. system('mkdir -p .symlinks/plugins')
  64. plugin_pods = parse_KV_file('../.flutter-plugins')
  65. plugin_pods.each do |name, path|
  66. symlink = File.join('.symlinks', 'plugins', name)
  67. File.symlink(path, symlink)
  68. pod name, :path => File.join(symlink, 'ios')
  69. end
  70. end
  71. # Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system.
  72. install! 'cocoapods', :disable_input_output_paths => true
  73. post_install do |installer|
  74. installer.pods_project.targets.each do |target|
  75. target.build_configurations.each do |config|
  76. config.build_settings['ENABLE_BITCODE'] = 'NO'
  77. # You can remove unused permissions here
  78. # for more infomation: https://github.com/BaseflowIT/flutter-permission-handler/blob/develop/permission_handler/ios/Classes/PermissionHandlerEnums.h
  79. # e.g. when you don't need camera permission, just add 'PERMISSION_CAMERA=0'
  80. config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
  81. '$(inherited)',
  82. ## dart: PermissionGroup.calendar
  83. 'PERMISSION_EVENTS=0',
  84. ## dart: PermissionGroup.reminders
  85. 'PERMISSION_REMINDERS=0',
  86. ## dart: PermissionGroup.contacts
  87. 'PERMISSION_CONTACTS=0',
  88. ## dart: PermissionGroup.camera
  89. # 'PERMISSION_CAMERA=0',
  90. ## dart: PermissionGroup.microphone
  91. # 'PERMISSION_MICROPHONE=0',
  92. ## dart: PermissionGroup.speech
  93. 'PERMISSION_SPEECH_RECOGNIZER=0',
  94. ## dart: PermissionGroup.photos
  95. # 'PERMISSION_PHOTOS=0',
  96. ## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
  97. 'PERMISSION_LOCATION=0',
  98. ## dart: PermissionGroup.notification
  99. # 'PERMISSION_NOTIFICATIONS=0',
  100. ## dart: PermissionGroup.mediaLibrary
  101. 'PERMISSION_MEDIA_LIBRARY=0',
  102. ## dart: PermissionGroup.sensors
  103. 'PERMISSION_SENSORS=0'
  104. ]
  105. end
  106. end
  107. end

Error

  1. NoMethodError - undefined method `size' for nil:NilClass
  2. /Library/Ruby/Gems/2.6.0/gems/ruby-macho-1.4.0/lib/macho/macho_file.rb:455:in `populate_mach_header'
  3. /Library/Ruby/Gems/2.6.0/gems/ruby-macho-1.4.0/lib/macho/macho_file.rb:233:in `populate_fields'
  4. /Library/Ruby/Gems/2.6.0/gems/ruby-macho-1.4.0/lib/macho/macho_file.rb:55:in `initialize_from_bin'
  5. /Library/Ruby/Gems/2.6.0/gems/ruby-macho-1.4.0/lib/macho/macho_file.rb:33:in `new_from_bin'
  6. /Library/Ruby/Gems/2.6.0/gems/ruby-macho-1.4.0/lib/macho/fat_file.rb:365:in `block in populate_machos'
  7. /Library/Ruby/Gems/2.6.0/gems/ruby-macho-1.4.0/lib/macho/fat_file.rb:364:in `each'
  8. /Library/Ruby/Gems/2.6.0/gems/ruby-macho-1.4.0/lib/macho/fat_file.rb:364:in `populate_machos'
  9. /Library/Ruby/Gems/2.6.0/gems/ruby-macho-1.4.0/lib/macho/fat_file.rb:156:in `populate_fields'
  10. /Library/Ruby/Gems/2.6.0/gems/ruby-macho-1.4.0/lib/macho/fat_file.rb:95:in `initialize'
  11. /Library/Ruby/Gems/2.6.0/gems/ruby-macho-1.4.0/lib/macho.rb:31:in `new'
  12. /Library/Ruby/Gems/2.6.0/gems/ruby-macho-1.4.0/lib/macho.rb:31:in `open'
  13. /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/xcode/linkage_analyzer.rb:16:in `dynamic_binary?'
  14. /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/sandbox/file_accessor.rb:171:in `block in vendored_dynamic_frameworks'
  15. /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/sandbox/file_accessor.rb:170:in `select'
  16. /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/sandbox/file_accessor.rb:170:in `vendored_dynamic_frameworks'
  17. /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/sandbox/file_accessor.rb:179:in `vendored_static_frameworks'
  18. /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/sandbox/file_accessor.rb:292:in `vendored_static_artifacts'
  19. /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer/xcode/target_validator.rb:82:in `each'
  20. /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer/xcode/target_validator.rb:82:in `flat_map'
  21. /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'
  22. /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer/xcode/target_validator.rb:74:in `each_key'
  23. /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'
  24. /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer/xcode/target_validator.rb:73:in `each'
  25. /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'
  26. /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer/xcode/target_validator.rb:38:in `validate!'
  27. /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer.rb:590:in `validate_targets'
  28. /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer.rb:158:in `install!'
  29. /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/command/install.rb:52:in `run'
  30. /Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
  31. /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/command.rb:52:in `run'
  32. /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/bin/pod:55:in `<top (required)>'
  33. /usr/local/bin/pod:23:in `load'
  34. /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…

and 4 more at: https://github.com/cocoapods/cocoapods/search?q=undefined%20method%20%60size%27%20for%20nil&type=Issues&utf8=✓

  1. <a name="uqEY2"></a>
  2. ## 3、解决方法
  3. ```bash
  4. flutter clean
  5. rm -Rf ios/Pods
  6. rm -Rf ios/.symlinks
  7. rm -Rf ios/Flutter/Flutter.framework
  8. rm -Rf ios/Flutter/Flutter.podspec
  9. flutter pub get
  10. cd ios
  11. pod install

4、参考链接

语雀内容