bazel-ios / cocoapods-bazel

A Cocoapods plugin for automatically generating Bazel BUILD files
Apache License 2.0
110 stars 21 forks source link

compiler_flags from pod spec not propagated to build file #63

Open ileitch opened 2 years ago

ileitch commented 2 years ago

The compiler_flags attribute in pod specs are ignored by cocoapods-bazel, which can result in that pod failing to build under Bazel. For example, the CNIODarwin pod requires -D__APPLE_USE_RFC_3542=1 in order to compile successfully on macOS.

The following addition to the Podfile serves as a temporary workaround:

pre_install do |installer|
  cniodarwin = installer.pod_targets.detect { |t| t.name == 'CNIODarwin' }
  cniodarwin.spec_consumers.each do |c|
    compiler_flags = c.spec.attributes_hash['compiler_flags']
    c.spec.attributes_hash['pod_target_xcconfig'] = {'OTHER_CFLAGS' => compiler_flags}
  end
end