Cocoapods header conflict between libopus and abseil

894 views Asked by At

I have an Xcode project with the following Podfile :

pod '!ProtoCompiler-gRPCPlugin', '~> 1.33'
pod 'gRPC', '~> 1.33'
pod 'libopus'

The issue is that since GRPC decide to use Abseil as a dependency, a weird conflict is happening. When compiling, I get the following error on Pods/abseil/base/config.h:

'absl/base/options.h' file not found

but the previous call in the stack is actually located in Pods/libopus/float/warped_autocorrelation_FLP.c :

#include "config.h"

This doesn't make sense as the specific config.h libopus is trying to get is actually in the same pod directory.

Any idea how to fix this? I tried multiple versions of libopus, but the static version is causing issues of its own.

1

There are 1 answers

0
Alexis C. On

It appears the conflict was caused by the HEADER_MAP = YES build setting "leaking" headers without proper namespacing.

The fix for this was to isolate libraries with header conflicts and then :

  • Setting their HEADER_MAP to NO
  • Add headers through HEADER_SEARCH_PATHS

To automate it in your Podfile :


post_install do |installer|

    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            # Prevent header conflicts
            if ['LIBRARY_A', 'LIBRARY_B'].include? target.name
                config.build_settings["USE_HEADERMAP"] = "NO"
                config.build_settings["HEADER_SEARCH_PATHS"] = "${PODS_TARGET_SRCROOT}/**"
            end
        end
    end

end