问题
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