Undefined symbols when adding an Objective-C framework to a Widget Extension

I'm trying to add an Objective-C framework to a Widget Extension but it fails to build when I try to initialise a instance of the main public class.

I have a bridging header and the compiler recognises it - code completion works in the widget code - but I have a number of undefined symbols errors.

Should it be possible? Is there some objc/c/c++ library I need to add to get it to work?


Undefined symbols for architecture arm64:
  "operator new[](unsigned long)", referenced from:
      ByteArray::alloc(int) in TheFramework.a(SomeClass.o)
      ByteArray::alloc(int) in TheFramework.a(SomeOtherClass.o)
  "operator new(unsigned long)", referenced from:
      -[TheFramework initWithName:] in TheFramework.a(SomeClass.o)
      SomeClass::CreatePublicKey() in TheFramework.a(SomeOtherClass.o)
  "___cxa_begin_catch", referenced from:
      ___clang_call_terminate in TheFramework.a(SomeClass.o)
  "std::terminate()", referenced from:
      ___clang_call_terminate in TheFramework.a(SomeClass.o)
  "___gxx_personality_v0", referenced from:
      -[TheFramework dealloc] in TheFramework.a(SomeClass.o)
      -[TheFramework initWithName:] in TheFramework.a(SomeClass.o)
      -[TheFramework getDataFromXml:] in TheFramework.a(SomeClass.o)
      -[TheFramework getCommandFromXml:] in TheFramework.a(SomeClass.o)
      -[TheFramework setConnectionDetails:] in TheFramework.a(SomeClass.o)
      -[TheFramework connect:] in TheFramework.a(SomeClass.o)
      -[TheFramework connect] in TheFramework.a(SomeClass.o)
      ...
  "operator delete(void*)", referenced from:
      -[TheFramework dealloc] in TheFramework.a(SomeClass.o)
      -[TheFramework initWithName:] in TheFramework.a(SomeClass.o)
      ByteArray::decRef() in TheFramework.a(SomeClass.o)
      SomeClass::Initialise() in TheFramework.a(SomeOtherClass.o)
      SomeClass::~SomeClass() in TheFramework.a(SomeOtherClass.o)
      SomeClass::CreatePublicKey() in TheFramework.a(SomeOtherClass.o)
      ByteArray::decRef() in TheFramework.a(SomeOtherClass.o)
      ...
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Edit: It is included in the Library Search Paths for the extension

Edit 2: TheFramework is using C++

Answered by reg890 in 698431022

Solved by adding libc++.tbd to Link Binary with Libraries in the Build Phases of the Widget Extension.

Try wrapping any C++ methods with Objective-C methods then only expose the Objective-C methods to Swift with a new Swift name. https://developer.apple.com/documentation/swift/objective-c_and_c_code_customization

Accepted Answer

Solved by adding libc++.tbd to Link Binary with Libraries in the Build Phases of the Widget Extension.

Undefined symbols when adding an Objective-C framework to a Widget Extension
 
 
Q