Swift and Objective C interoperabiloty

I am working on the project in which we are migrating from iOS project to framework. I am facing issue with Objective-C and swift interoperability.

I have one Swift class let suppose profile, it has been exposed to objective c

import Foundation

@objc public class Profile: NSObject {

@objc public var name : String?
@objc public func getName() -> String{
    return "XYZ"
}

} When I am importing “ProductName-Swift.h” it is showing me error in generated header for the module map like “@import ModuleMapPrivate not found”

I wanted to know is there any way in which I can import “Profile-Swift.h” instead of “ProductName-Swift.h” ?

Maybe you are looking for the Build Settings related to "module name", in the Packaging section?

I wanted to know is there any way in which I can import Profile-Swift.h instead of ProductName-Swift.h?

Why does that matter to you?

Swift doesn’t generate a .h file for each Swift class that you export to Objective-C. Rather, it generates a single .h for the entire module. Thus you can’t import a single header like you might for a class declared natively in Objective-C. You have to always import the module.

As ssmith_c noted, you can change the module name via a build setting, but I think it makes more sense to stick with the default.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Agree with @eskimo, however I think the actual problem faced by @shikha25 is:

Error in generated Swift header due to @import ModuleMapPrivate in it
Swift and Objective C interoperabiloty
 
 
Q