I am new in iOS. I have a lib that I use in my App both in Swift and Objc files (I have connected my lib correctly including the *-Swift.h file).
So, my lib has such a structure
Factory
import Foundation
@objc public class Factory : NSObject{
@objc public func create() -> ModelProtocol
{
return FirstModel()
}
}
Model protocol
import Foundation
@objc public protocol ModelProtocol
{
func foo()
}
First Model
import Foundation
public class FirstModel : NSObject, ModelProtocol
{
public func foo() {
//Do some things here
}
}
when I try to use this factory on the Swift side everything is working properly
import Foundation
import Lib
class TestClass {
public init(){}
func boo()
{
let factory = Factory()
let _: ModelProtocol = factory.create()
}
}
but when I try to do the same on the Objc side I got an error
Use of undeclared identifier 'ModelProtocol'
#import <Foundation/Foundation.h>
#import "Lib-Swift.h"
@implementation ViewController : NSObject
- (void)foo {
Factory *factory = [Factory new];
ModelProtocol *protocol = [factory create];
}
@end
also I put both these projects (lib & app) on my drive https://drive.google.com/drive/folders/1-DMYMhTqTqpgHcp31DNVby7US46OXUYM?usp=sharing
How to fix it?