Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift and Objective-C framework exposes its internals

I’m trying to add Swift to an existing Objective-C framework that has public, private and project files. In order for Swift to access the project files, I added a modulemap that defines a new module (e.g. MyFramework_Internal) by including all the project headers as explained here: http://nsomar.com/project-and-private-headers-in-a-swift-and-objective-c-framework/

That setup is sort of working but one thing I was surprised to see is that now a client can access the internal classes by importing MyFramework_Internal (i.e. @import MyFramework_Internal). Is there a way to hide the module since it's only needed by the framework itself? The modulemap looks like this now:

module MyFramework_Internal {  
   header "Folder1/Baz.h"  
   header "Folder1/Folder2/Bar.h"  
   export *
} 
like image 934
Glauco Avatar asked Nov 18 '25 11:11

Glauco


1 Answers

The modulemap file is intended for Objective-C and Objective-C doesn't have the concept of internal. It only knows public (what's declared in the header files), and private (what's declared only in the implementation files).

Thus, anything that ends up in a modulemap file will be publicly available.

like image 102
Cristik Avatar answered Nov 20 '25 03:11

Cristik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!