7

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.

Xavier Lowmiller
  • 1,381
  • 1
  • 15
  • 24
Loegic
  • 3,390
  • 20
  • 33

1 Answers1

15

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' }
iwasrobbed
  • 46,496
  • 21
  • 150
  • 195
Loegic
  • 3,390
  • 20
  • 33
  • Hey, I got the non modular error. Can you explain a little bit what you did here? Thanks – La masse Oct 31 '15 at 18:16
  • It depend on with header you have a modular header. You can try to use the @import syntax if you have the error on a #import <> syntax. Here you create a module.modulemap file, in which you place the declaration of your module (in my case libxml). Then you add it to your build settings to allow Xcode to use it, and compile – Loegic Nov 02 '15 at 08:58
  • 1
    Moving the libxml2 location from `pod_target_xcconfig` to `xcconfig` did the trick for me. Thank you! – diegoreymendez Sep 06 '16 at 16:45
  • Can you post your `module.modulemap` file for completion? I tried `pod lint` with all possible variants of the samples above, but I cannot get it to succeed. Do you still have to link against `xml2` with `s.libraries = 'xml2'`? – rpitting Nov 07 '16 at 16:36
  • @Loegic can you post the content of your .modulemap file? – Martin Aug 17 '17 at 00:21
  • @Cyrus, it was a long time ago, but I think that if you search under my other answer you'll find an example – Loegic Aug 21 '17 at 16:11