Xcode 7.3 cannot create __weak reference in file using manual reference counting

后端 未结 7 2002
清酒与你
清酒与你 2020-12-12 12:50

After updating to Xcode 7.3, it throws the error Cannot create __weak reference in file using manual reference counting in pod files. Has anyone solved this iss

7条回答
  •  甜味超标
    2020-12-12 13:37

    The best way to solve this is to add a post_install script to your Podfile that sets the Weak References in Manual Retain Release flag to yes in all your pod targets. To do that just paste the following code at the bottom of your Podfile.

    post_install do |installer_representation|
        installer_representation.pods_project.targets.each do |target|
            target.build_configurations.each do |config|
                config.build_settings['CLANG_ENABLE_OBJC_WEAK'] ||= 'YES'
            end
        end
    end
    

    Sometimes, doing that result in the error -fobjc-weak is not supported on the current deployment target. You can solve that by adding another configuration option, forcing all the pods to target the version you want (based on this answer):

    post_install do |installer_representation|
        installer_representation.pods_project.targets.each do |target|
            target.build_configurations.each do |config|
                config.build_settings['CLANG_ENABLE_OBJC_WEAK'] ||= 'YES'
                config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.3'
            end
        end
    end
    

提交回复
热议问题