Swift and Objective-c framework exposes its internals

独自空忆成欢 提交于 2020-01-02 01:10:15

问题


I’m trying to integrate Swift into 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 (@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 *
} 

回答1:


The module 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 end's up in a module file will be publicly available.



来源:https://stackoverflow.com/questions/53173819/swift-and-objective-c-framework-exposes-its-internals

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!