Define custom module map file in cocoapods Podspec

Loegic picture Loegic · Aug 28, 2015 · Viewed 7.4k times · Source

I made a custom module map file to handle the libxml import in a swift project. (non-modular include error)

It's working great if I do it manually, but cocoapods won't find / resolve the module when I try to pod lint a simple project containing an import from this custom module.

I tried s.module_map = "module/module.modulemap" along with

core.xcconfig = {
  'HEADER_SEARCH_PATHS' => '$(SDKROOT)/usr/include/libxml2 $(SRCROOT)/module $(SDKROOT)/usr/include/libresolv',
  'OTHER_LDFLAGS' => '"-lxml2"',
  'CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'YES',
  'ENABLE_BITCODE' => 'NO',
  "SWIFT_INCLUDE_PATHS" => "$(SRCROOT)/module"
}

Any help would be appreciated.

Answer

Loegic picture Loegic · Sep 2, 2015

I managed to fix this issue by setting the pod_target_xcconfig property. The complete part looks like that :

s.preserve_path = 'module/module.modulemap'
s.module_map = 'module/module.modulemap'

core.pod_target_xcconfig = { 'HEADER_SEARCH_PATHS' => '$(PODS_ROOT)/mypod/module' }
core.xcconfig = { 'HEADER_SEARCH_PATHS' => '$(SDKROOT)/usr/include/libxml2 $(PODS_ROOT)/mypod/module' }