'XCode C++, how to use boost dependency from cocoapods?

I'm creating a C++ library for iOS and React-Native. I need to access some helper code from the boost framework, which React-Native itself already has as a dependency.

However, when I try to include the header Xcode tells me it cannot be found:

enter image description here

My library itself is meant to be packaged as a Cocoapods dependency, therefore, I've tried adding the boost dependency to the .podspec but that doesn't seem to do anything to expose the headers.

require "json"

package = JSON.parse(File.read(File.join(__dir__, "package.json")))

Pod::Spec.new do |s|
  s.name         = "react-native-wallet-core"
  s.version      = package["version"]
  s.summary      = package["description"]
  s.homepage     = package["homepage"]
  s.license      = package["license"]
  s.authors      = package["author"]

  s.platforms    = { :ios => "14.0" }
  s.source       = { :git => "---.git", :tag => "#{s.version}" }


  s.source_files = "ios/**/*.{h,m,mm}", "cpp/**/*.{h,cpp}"

  s.dependency "React-Core"
  s.dependency "TrustWalletCore", '~>2.7.2'
  # Doesn't seem to do anything
  s.dependency "boost"
  # doesn't work cannot use path in a podspec
  # s.dependency "boost", path: "../node_modules/react-native/third-party-podspecs/boost.podspec" 
end

Any idea what do I need to do to be able to use boost code inside my own C++ code?



Solution 1:[1]

I got it working, apparently even though the dependency is declared and it is part of react-native, the header path is not immediately available, one needs to add header search paths as part of the podspec itself:

  s.pod_target_xcconfig = {
    "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\" \"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/libevent/include/\""
  }
  s.user_target_xcconfig = {
    "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\""
  }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Oscar Franco