未定义的方法`__apply_Xcode_12_5_M1_post_install_workaround'

undefined method `__apply_Xcode_12_5_M1_post_install_workaround'

我在全新的 react-native 安装和尝试安装 pod 时遇到以下错误。

[!] An error occurred while processing the post-install hook of the Podfile.

undefined method `__apply_Xcode_12_5_M1_post_install_workaround' for #<Pod::Podfile:0x00000001068fad98 @defined_in_file=#<Pathname:/Users/fullmad/Projects/saga-reserve/sagaMobile/ios/Podfile>, @internal_hash={}, @root_target_definitions=[#<Pod::Podfile::TargetDefinition label=Pods>], @current_target_definition=#<Pod::Podfile::TargetDefinition label=Pods>, @post_install_callback=#<Proc:0x000000012a01a6a0 /Users/fullmad/Projects/saga-reserve/sagaMobile/ios/Podfile:26>, @installation_options=#<Pod::Installer::InstallationOptions:0x00000001068b6148 @clean=true, @deduplicate_targets=true, @deterministic_uuids=true, @integrate_targets=true, @lock_pod_sources=true, @warn_for_multiple_pod_sources=true, @warn_for_unused_master_specs_repo=true, @share_schemes_for_development_pods=false, @disable_input_output_paths=false, @preserve_pod_file_structure=false, @generate_multiple_pod_projects=false, @incremental_installation=false, @skip_pods_project_generation=false>>

/Users/fullmad/Projects/saga-reserve/sagaMobile/ios/Podfile:28:in `block (3 levels) in from_ruby'
/opt/homebrew/Cellar/cocoapods/1.11.2_1/libexec/gems/cocoapods-core-1.11.2/lib/cocoapods-core/podfile.rb:196:in `post_install!'
/opt/homebrew/Cellar/cocoapods/1.11.2_1/libexec/gems/cocoapods-1.11.2/lib/cocoapods/installer.rb:945:in `run_podfile_post_install_hook'
/opt/homebrew/Cellar/cocoapods/1.11.2_1/libexec/gems/cocoapods-1.11.2/lib/cocoapods/installer.rb:933:in `block in run_podfile_post_install_hooks'
/opt/homebrew/Cellar/cocoapods/1.11.2_1/libexec/gems/cocoapods-1.11.2/lib/cocoapods/user_interface.rb:149:in `message'
/opt/homebrew/Cellar/cocoapods/1.11.2_1/libexec/gems/cocoapods-1.11.2/lib/cocoapods/installer.rb:932:in `run_podfile_post_install_hooks'
/opt/homebrew/Cellar/cocoapods/1.11.2_1/libexec/gems/cocoapods-1.11.2/lib/cocoapods/installer.rb:331:in `block (2 levels) in create_and_save_projects'
/opt/homebrew/Cellar/cocoapods/1.11.2_1/libexec/gems/cocoapods-1.11.2/lib/cocoapods/installer/xcode/pods_project_generator/pods_project_writer.rb:61:in `write!'
/opt/homebrew/Cellar/cocoapods/1.11.2_1/libexec/gems/cocoapods-1.11.2/lib/cocoapods/installer.rb:330:in `block in create_and_save_projects'
/opt/homebrew/Cellar/cocoapods/1.11.2_1/libexec/gems/cocoapods-1.11.2/lib/cocoapods/user_interface.rb:64:in `section'
/opt/homebrew/Cellar/cocoapods/1.11.2_1/libexec/gems/cocoapods-1.11.2/lib/cocoapods/installer.rb:309:in `create_and_save_projects'
/opt/homebrew/Cellar/cocoapods/1.11.2_1/libexec/gems/cocoapods-1.11.2/lib/cocoapods/installer.rb:301:in `generate_pods_project'
/opt/homebrew/Cellar/cocoapods/1.11.2_1/libexec/gems/cocoapods-1.11.2/lib/cocoapods/installer.rb:180:in `integrate'
/opt/homebrew/Cellar/cocoapods/1.11.2_1/libexec/gems/cocoapods-1.11.2/lib/cocoapods/installer.rb:167:in `install!'
/opt/homebrew/Cellar/cocoapods/1.11.2_1/libexec/gems/cocoapods-1.11.2/lib/cocoapods/command/install.rb:52:in `run'
/opt/homebrew/Cellar/cocoapods/1.11.2_1/libexec/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
/opt/homebrew/Cellar/cocoapods/1.11.2_1/libexec/gems/cocoapods-1.11.2/lib/cocoapods/command.rb:52:in `run'
/opt/homebrew/Cellar/cocoapods/1.11.2_1/libexec/gems/cocoapods-1.11.2/bin/pod:55:in `<top (required)>'
/opt/homebrew/Cellar/cocoapods/1.11.2_1/libexec/bin/pod:23:in `load'
/opt/homebrew/Cellar/cocoapods/1.11.2_1/libexec/bin/pod:23:in `<main>'

如果您不使用基于 M1 的计算机来构建,您可以在您的 Podfile 中注释“__apply_Xcode_12_5_M1_post_install_workaround(installer)”行。

检查 ios/Podfile 语法和我们的 __apply_Xcode_12_5_M1_post_install_workaround Ruby 方法的定义(可能值得 rm -rf node_modules && yarn 以防万一)

# node_modules/react-native/scripts/react_native_pods.rb

# ...

def __apply_Xcode_12_5_M1_post_install_workaround(installer)
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
      end
  end

  `sed -i -e  $'s/__IPHONE_10_0/__IPHONE_12_0/' Pods/RCT-Folly/folly/portability/Time.h`
end

这是最小的 template to check out the Podfile

如果您使用的是基于 M1 的计算机,您仍然可以在 Podfile 中注释“__apply_Xcode_12_5_M1_post_install_workaround(installer)”行,并且 运行 命令 arch -x86_64 pod install 而不是 pod install.

Better Support for Apple Silicon, Xcode 13, and iOS