Hi
We're building a binary framework and using Objective-C as the main language in the codebase with some files there written in Swift.
In order for us to expose our Swift classes to Objective-C, is by marking them public
or open
. As it's described here in Apple's documentation blog.
Now, that also exposes our Swift classes to the client too, and what we want is to expose them only to our framework target. Is there a way for us to do that?
Note: I quoted the following from Apple's docs.
Import Code Within a Framework Target
To import a set of Swift files in the same framework target as your Objective-C code, import the Xcode-generated header for your Swift code into any Objective-C
.m
file where you want to use your Swift code.Because the generated header is part of the frameworkâs public interface, only declarations marked with the
public
oropen
modifier appear in the generated header for a framework target. Methods and properties that are marked with theinternal
modifier and declared within a class that inherits from an Objective-C class are accessible to the Objective-C runtime. However, they're inaccessible at compile time and don't appear in the generated header for a framework target.Import Swift code into Objective-C within the same framework:
- Under Build Settings, in Packaging, make sure the Defines Module setting for that framework target is set to Yes.
- Import the Swift code from that framework target into any Objective-C
.m
file within that target using this syntax and substituting the appropriate names:#import <ProductName/ProductModuleName-Swift.h>