Loegic Loegic - 6 months ago 115
Swift Question

Define custom module map file in cocoapods Podspec

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

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 }