I was testing my framework APIs. My framework has the following sample code
open class TestManager {
let appendStringHandler: (String, String) -> String
public init(appendHandler: @escaping (String, String) -> String = TestManager.appendStringObject(text1:text2:)) {
self.appendStringHandler = appendHandler
}
public class func appendStringObject(text1: String, text2: String) -> String {
return text1+text2
}
public func printString() {
print(appendStringHandler("test1", "test2"))
}
}
I am creating an object like this let test = TestManager() in my project which is using the framework.
I am getting the following error while building in Debug mode and in Xcode 14.3
Undefined symbols for architecture x86_64: "_$s17ReusableComponent11TestManagerC18appendStringObject5text15text2S2S_SStFZ", referenced from: $s17ReusableComponent11TestManagerC13appendHandlerACS2S_SStc_tcfcfA_S2S_SStcfu in ViewController.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
After some investigation found out that changing the debug Compilation Mode to "Incremental" is fixing the issue.
Observations: Xcode 14.2: There is no issue when Compilation Mode is "Whole Module" in Debug/Release both Xcode 14.3: Having issue when Compilation Mode is "Whole Module" in Debug. Release Mode doesn't have any issue with "Whole Module" mode.
I was wondering what changed in xcode 14.3? Please let us know how can I stick with the "Whole Module" compilation mode without the error.