未定义方法`__apply_Xcode_12_5_M1_post_install_workaround'

问题描述 投票:0回答:4

我在新的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>'

xcode react-native cocoapods
4个回答
7
投票

如果您使用的是基于 M1 的计算机,您仍然可以在 Podfile 中注释“__apply_Xcode_12_5_M1_post_install_workaround(installer)”行并运行命令

arch -x86_64 pod install
而不是
pod install

更好地支持 Apple Silicon、Xcode 13 和 iOS


6
投票

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


6
投票

检查

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

这是一个最小的模板,用于查看Podfile


0
投票

要有条件地应用适用于 M1 Macs 的解决方法,请按照以下步骤操作:

post_install do |installer|
....
  if installer.respond_to?(:__apply_Xcode_12_5_M1_post_install_workaround)
    installer.__apply_Xcode_12_5_M1_post_install_workaround
  end
....
end
  • 代码检查安装程序对象是否具有方法 __apply_Xcode_12_5_M1_post_install_workaround,表明与 M1 Mac 兼容。
  • 如果兼容,它会调用该方法来应用解决方法。
  • 否则,它会跳过解决方法,防止非 M1 设备上出现错误。
© www.soinside.com 2019 - 2024. All rights reserved.