0

So I think I have this kinda clear, based on this blog post and my experiments:

  • what's included by @import MyPod; is the auto-generated MyPod-umbrella.h header, which imports all the public headers according to the Podspec
  • the auto-generated module map also permits explicit import of those and only those same public headers
  • what's included by #import <MyPod/MyPod.h> header is a MyPod.h header that I still need to make, but it can import anything I choose that's in the module map

What I was hoping to achieve, however, was that the header for either @import or #import to include most but not all of my pod's public headers. I'd like one of my public headers contain optional declarations that are normally omitted, to only be included manually from the few .m files that need it. But it seems to not be possible when code uses @import since the includes in that umbrella header always matches all the public headers.

Specifying a custom module map is possible and would work, but doing that seems to precludes the benefits of auto-generated map & umbrella header.

Would it be kosher to do some macro & #ifdef tricks to skip the contents of my "optional" header when included by the @import but then use the contents if that header is pulled in again with an #include? This sounds ugly, but is it my only option?

Pierre Houston
  • 1,631
  • 20
  • 33

1 Answers1

0

I found problems with all the #ifdef tricks I attempted when using framework cocoapods, though I'm sure they'd work when not. But I don't really want to be biased against frameworks and would like a solution for both.

So to take another approach, I found its not hard for a project to access a pod's private headers! See here and here (that last tip is for Swift, but I'm sure the right @import will work in Objective-C too).

So in my cocoapod I'm going to make the optional header private, and then rely on my users to use those methods to access it if desired.

Community
  • 1
  • 1
Pierre Houston
  • 1,631
  • 20
  • 33