1
votes

I'm trying to create an iOS swift framework that encapsulates a set of functionality, some of which requires wrapping a c/objective-c static library. I need to call the objective-c wrapper functions from within the framework -- as best I understand (based on documentation on how to mix and match objc and swift within a framework target: https://developer.apple.com/library/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html), I must import the objective-c header(s) within my umbrella header to expose the objective-c to the swift code within the framework. This also exposes the objective-c wrapper to any consumer of my framework. How can I avoid doing this? I want to be able to call the objective-c wrapper functions from swift code within my framework but not expose the wrapper itself to any framework consumers ...

1

1 Answers

0
votes

Just updating this with an answer -- I asked an engineer from apple this question at WWDC. Exactly what I wanted is not possible with swift.

In my case the objective-c api that I wanted to be callable from within my swift framework was very small, so it sufficed to make a small (private) swift class that uses runtime dispatch (performSelector) to invoke the appropriate methods after casting to AnyObject. This requires manually maintaining a swift selector definition that duplicates each method declaration in the objective-c header file -- but for a very small constrained scenario, this isn't that bad (even though its not the ideal).