Add import to module_map or umbrella header

Viewed 643

I wonder If there exists any way to change the content of PodName-umbrella.h? Or somehow to pass my own through podspec DSL.

I need to add import to umbrella header or ideally change all content to this:

// PodName-umbrella.h
@import MyAnotherPod;

Also, I can use a custom module_map. But I couldn't figure out how to use the correct path to the header file from my pod.

framework module PodName {
    header "MyAnotherPod.h" // ⛔️ Header 'MyAnotherPod.h' not found
}
1 Answers

By the way, I found the solution!

I created the custom umbrella headerMyPod/Sources/MyPod-umbrella.h.
And added imports of pods which I want to be available with import MyPod:

@import MyAnotherPod;

Then I created the custom modulemapMyPod/MyPod.modulemap:

framework module MyPod {
    umbrella header "MyPod-umbrella.h"
    export *
}

And finally in ./MyPod.podspec:

# Add MyPod-umbrella.h to sources
s.source_files = "#{s.name}/Sources/**/*.{swift,h}"

# Select custom module map
s.module_map = "#{s.name}/#{s.name}.modulemap"

After these changes I just can write:

import MyPod
// And it also imports MyAnotherPod like
// import MyAnotherPod
Related