Call Objective-C from Swift within a Framework target WITHOUT making Objective-C methods public

Hello, I'm working on a mixed-source (Objective-C + Swift) framework project and need to call some Objective-C methods from Swift. However, I do not want to make the Objective-C methods public in doing so. Previously, this could be accomplished using a bridging header, but bridging headers are no longer supported in a framework target. The following article explains how this can be done via an umbrella header instead:


https://developer.apple.com/documentation/swift/imported_c_and_objective-c_apis/importing_objective-c_into_swift


But it seems that using an umbrella header to bridge Objective-C to Swift requires making the Objective-C APIs public, which I do not want. Is there a supported way to bridge Objective-C to Swift within a framework without making the Objective-C methods public?

Alright found a perfect working solution:


1. Create 'module.modulemap' file inside your framework folder


module YourFramework_Private {
    header "Location/To/Private-Header.h"
    export *
}


2. Set "Import Paths" to the folder containing 'module.modulemap' file. For example: $(SRCROOT)/YourFramework

3. Then you can import that Private module inside any file within your Framework. But this private module is not going to be visible outside your framework


import YourFramework_Private


Reply in this post if you have questions or Approve this as a correct answer if this fixes your issue.


Thank you

Call Objective-C from Swift within a Framework target WITHOUT making Objective-C methods public
 
 
Q