Using private Objective-C files from Swift within the same framework

We currently have a legacy Objective-C framework that we'd like to introduce some Swift components into. However, I can't figure out how to access the Private- and Project-scoped Objective-C files from our Swift files.


We already use an umbrella header and a modulemap file to declare the public headers that should be included in the library's module, and we want to keep these as the only publicly exposed files. However, our new Swift files (within the same framework) need to also access private headers that we don't want to expose.


I've already tried defining a private modulemap file that lists the private headers I want to use, and then specified it with the MODULEMAP_PRIVATE_FILE build setting, but I dont think this does what we want. It appears to introduce a new MyLibrary.Private module which is publicly visible to external targets (such as the unit test target) but is still not available to the Swift files within the framework.


Any suggestions of how this can be accomplished, or experience doing this in other projects would be greatly appreicated.


Thanks!

Replies

I have a similar issue, any updates on this ?


In case nothing works the solution that I see, will be to change what is private to public, all the swift files will already be public.

Create a warpper framework from which you limit what you are exporting, so basically put your framework in another framework.


In my case, we have a project with 2 targets, one for internal use, and another one for external use(third parties). The external target has a lot less exposed files.

  • It's been a while, but I wondered how you kept the internal framework headers private? I had a go at doing this briefly and everything in the 'internal' framework was public to both the 'public' framework and whatever was relying on that 'public' framework (e.g. an app)

Add a Comment