简体   繁体   English

Flutter 应用程序无法编译,CocoaPods Pod 安装失败

[英]Flutter App won't compile, CocoaPods fails Pod Install

I have an Image Picker dependency in my app, it's always worked fine as far as I'm aware and all of a sudden I can't compile my app for iOS. It's throwing me an error related to CocoaPods, I'm really not sure what to do about it.我的应用程序中有一个 Image Picker 依赖项,据我所知,它一直运行良好,突然间我无法为 iOS 编译我的应用程序。它向我抛出与 CocoaPods 相关的错误,我真的不是确定该怎么做。 Error is below, do you have any idea what I could do to resolve that situation?错误在下面,你知道我能做些什么来解决这种情况吗? Thanks in advance !提前致谢 !

### Stack


   CocoaPods : 1.11.3
        Ruby : ruby 3.2.0 (2022-12-25 revision a528908271) [arm64-darwin21]
    RubyGems : 3.4.2
        Host : macOS 12.6.1 (21G217)
       Xcode : 14.0.1 (14A400)
         Git : git version 2.37.0 (Apple Git-136)
Ruby lib dir : /opt/homebrew/Cellar/ruby/3.2.0/lib
Repositories : trunk - CDN - https://cdn.cocoapods.org/


### Plugins


cocoapods-deintegrate : 1.0.5
cocoapods-plugins     : 1.0.0
cocoapods-search      : 1.0.1
cocoapods-trunk       : 1.6.0
cocoapods-try         : 1.2.0


### Podfile

ruby
# Uncomment this line to define a global platform for your project
platform :ios, '11.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 flutter_root
  generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
  unless File.exist?(generated_xcode_build_settings_path)
    raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  end

  File.foreach(generated_xcode_build_settings_path) do |line|
    matches = line.match(/FLUTTER_ROOT\=(.*)/)
    return matches[1].strip if matches
  end
  raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)

    # Workaround https://github.com/flutter/flutter/issues/111475.
    target_is_resource_bundle = target.respond_to?(:product_type) && target.product_type == 'com.apple.product-type.bundle'
    target.build_configurations.each do |build_configuration|
      if target_is_resource_bundle
        build_configuration.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
        build_configuration.build_settings['CODE_SIGNING_REQUIRED'] = 'NO'
        build_configuration.build_settings['CODE_SIGNING_IDENTITY'] = '-'
        build_configuration.build_settings['EXPANDED_CODE_SIGN_IDENTITY'] = '-'
      end
    end

    target.build_configurations.each do |config|
      # You can remove unused permissions here
      # for more infomation: https://github.com/BaseflowIT/flutter-permission-handler/blob/master/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=1',

        ## dart: PermissionGroup.reminders
#        'PERMISSION_REMINDERS=1',

        ## dart: PermissionGroup.contacts
#        'PERMISSION_CONTACTS=1',

        ## dart: PermissionGroup.camera
        'PERMISSION_CAMERA=1',

        ## dart: PermissionGroup.microphone
#         'PERMISSION_MICROPHONE=1',

        ## dart: PermissionGroup.speech
#        'PERMISSION_SPEECH_RECOGNIZER=1',

        ## dart: PermissionGroup.photos
#        'PERMISSION_PHOTOS=1',

        ## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
        'PERMISSION_LOCATION=1',

        ## dart: PermissionGroup.notification
#        'PERMISSION_NOTIFICATIONS=1',

        ## dart: PermissionGroup.mediaLibrary
#         'PERMISSION_MEDIA_LIBRARY=1',

        ## dart: PermissionGroup.sensors
#        'PERMISSION_SENSORS=1',

        ## dart: PermissionGroup.bluetooth
#        'PERMISSION_BLUETOOTH=1',

        ## dart: PermissionGroup.appTrackingTransparency
#        'PERMISSION_APP_TRACKING_TRANSPARENCY=1',

        ## dart: PermissionGroup.criticalAlerts
#        'PERMISSION_CRITICAL_ALERTS=1',
      ]

    end
  end
end


### Error


NoMethodError - undefined method `=~' for [["PICKER_MEDIA=1"], ["PICKER_AUDIO=1"], ["PICKER_DOCUMENT=1"]]:Array
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-1.11.3/lib/cocoapods/target/build_settings.rb:446:in `block (2 levels) in merged_xcconfigs'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-1.11.3/lib/cocoapods/target/build_settings.rb:446:in `all?'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-1.11.3/lib/cocoapods/target/build_settings.rb:446:in `block in merged_xcconfigs'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-1.11.3/lib/cocoapods/target/build_settings.rb:444:in `each'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-1.11.3/lib/cocoapods/target/build_settings.rb:444:in `each_with_object'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-1.11.3/lib/cocoapods/target/build_settings.rb:444:in `merged_xcconfigs'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-1.11.3/lib/cocoapods/target/build_settings.rb:1057:in `block in <class:PodTargetSettings>'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-1.11.3/lib/cocoapods/target/build_settings.rb:120:in `block in define_build_settings_method'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb:177:in `block in remove_pod_target_xcconfig_overrides_from_target'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb:174:in `each'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb:174:in `remove_pod_target_xcconfig_overrides_from_target'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb:157:in `block in add_target'
<internal:kernel>:90:in `tap'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb:156:in `add_target'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb:47:in `block in install!'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-1.11.3/lib/cocoapods/user_interface.rb:149:in `message'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb:40:in `install!'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer/xcode/pods_project_generator.rb:115:in `block in install_pod_targets'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer/xcode/pods_project_generator.rb:112:in `map'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer/xcode/pods_project_generator.rb:112:in `install_pod_targets'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer/xcode/single_pods_project_generator.rb:32:in `block in install_all_pod_targets'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-1.11.3/lib/cocoapods/user_interface.rb:149:in `message'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer/xcode/single_pods_project_generator.rb:31:in `install_all_pod_targets'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer/xcode/single_pods_project_generator.rb:19:in `generate!'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:314:in `block in create_and_save_projects'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-1.11.3/lib/cocoapods/user_interface.rb:64:in `section'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:309:in `create_and_save_projects'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:301:in `generate_pods_project'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:180:in `integrate'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:167:in `install!'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-1.11.3/lib/cocoapods/command/install.rb:52:in `run'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/claide-1.1.0/lib/claide/command.rb:334:in `run'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-1.11.3/lib/cocoapods/command.rb:52:in `run'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/gems/cocoapods-1.11.3/bin/pod:55:in `<top (required)>'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/bin/pod:25:in `load'
/opt/homebrew/Cellar/cocoapods/1.11.3_1/libexec/bin/pod:25:in `<main>'

Running brew reinstall cocoapods fixed the issue.运行brew reinstall cocoapods解决了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM