Currently i am working on bundle project, which has a mix of objective c and swift code in a bundle project. Here is my sample code goes, where I have written a function in Objective C which internally calls swift code for a specific operation. I am successfully able to write and execute a unit test for a objective C functions which contains objective C code only, but, if the same objective C function contains swift code like creating instance for a swift class) where my unit test project fails to compile.
Error:
Undefined symbol: _OBJC_CLASS_$__TtC12SampleBundle11SwiftClass
Example:
SwiftClass.swift
------------------
@objc public class SwiftClass: NSObject {
@objc func doSomething() {
print(" I am in swift ")
}
ObjcClass.m
---------------
@implementation ObjcClass
- (void)doBSomethingobjc {
printf("\n ---------I am in objc--------- \n");
SwiftClass *obj = [SwiftClass alloc]; // Without this unit test runs. //With this i am seeing compilation error, undefined symbol
[obj doSomething];
}
@end
Appreciate your valuable inputs.