Search code examples
xcodelinkerframeworksstatic-librarieslinker-errors

Undefined symbols for architecture arm64 in Xcode


I have a framework Xcode project A, and an app Xcode project B that uses the framework binary of A.

When I try to instantiate an object of my framework in my app, it gives me this link error :

Undefined symbols for architecture arm64:
  "_OBJC_CLASS_$_MyClass", referenced from:
      objc-class-ref in ViewController.o
ld: symbol(s) not found for architecture arm64

My framework is arm64, I verified with lipo -info .

The symbol _OBJC_CLASS_$_MyClass is in the framework, I verified with nm mylib | grep MyClass

I don't understand how it is possible that this symbol is not found.

What could be the cause of this ? Any help would be appreciated, thanks a lot..


Solution

  • I solved my issue by setting Symbols Hidden by Default to No in the build settings.

    Or, I could also add __attribute__ ((visibility("default"))) in front of my class if I wanted to keep that option and hide all other symbols.