C API for a Swift framework – always exposed?

限于喜欢 提交于 2021-01-29 05:44:45

问题


I am building a iOS SDK in Swift 5.3, and I define all classes (except the documented API) as internal (i.e. using the default access wherever I cannot use private). The SDK is distributed as a cocoapod dynamic framework. So far so good.

My SDK has a C component; these functions are used internally for some calculation, and are not expected to be exposed to the app developers. These are exposed to Swift via the unmbrella header, and my Swift code works with them as expected. Unfortunately, they are also exposed by the Framework, and an app that imports my framework, can call these C functions. They are even displayed as suggestions in code completion.

I thought that I could declare these functions in a separate file and declare it as a Project Header, but alas, these functions cannot be called from my Swift classes.

The last resort is, probably, to manipulate the file header while copying it to the Framework. Am I missing something? Are there better ways to obfuscate the internal C functions?

来源:https://stackoverflow.com/questions/65396920/c-api-for-a-swift-framework-always-exposed

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