日々精進

新しく学んだことを書き留めていきます

cocoa podのpost_installフックを使ってAFNetworkingの自己証明書を許可する

Podfileに以下を追加すればよい。

post_install do |installer_representation|
  installer_representation.project.targets.each do |target|
    if target.name == 'Pods-AFNetworking'
      target.build_configurations.each do |config|
        config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)']
        config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << '_AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_=1'
      end
    end
  end
end

参考:objective c - I want to allow invalid SSL certificates with AFNetworking - Stack Overflow