【Cocoapods】遇到 undefined method `targets' for nil:nilclass 的問題
報(bào)錯(cuò)信息: [!] an error occurred while processing the post-install hook of the podfile.
undefined method `targets' for nil:nilclass
看到這個(gè)警告一般會(huì)在Podfile的最底部添加以下代碼:會(huì)報(bào)錯(cuò)
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '8.0'
end
end
end
[!] an error occurred while processing the post-install hook of the podfile.
undefined method `targets' for nil:nilclass*
但是在新版本cocoapods中使用了新特性 install! 'cocoapods', :generate_multiple_pod_projects => true, :incremental_installation => true
來加快編譯的速度荐绝。
就會(huì)出現(xiàn)undefined methodtargets' for nil:NilClass`的提示级遭,提示:targets找不到了碍彭。所以要使用新的方式捍掺,如下:
post_install do |installer|
installer.pod_target_subprojects.flat_map { |p| p.targets }.each do |t|
t.build_configurations.each do |c|
c.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '10.0'
end
end
end
老項(xiàng)目刪除pods文件夾厨内,執(zhí)行 pod install --verbose
就好了捞奕。