Undefined symbols for architecture .. in dynamic f

2019-03-31 02:19发布

问题:

I am working on an iOS framework which holds several third party frameworks and communicates with Unity using the UnitySendMessage C method.

I want to create a Dynamic Framework (supporting iOS8+) but i stumble upon the following compile error:

Undefined symbols for architecture arm64:
   "_UnitySendMessage", referenced from:
 ....
ld: symbol(s) not found for architecture arm64

This method is called in my .m class and declared as shown below in my .h file:

void UnitySendMessage(const char* obj, const char* method, const char* msg);

When compiling as a static library it compiles and works fine but i get other crashes on the embedded 3rd party frameworks. As i can't control these frameworks i prefer to create a dynamic framework.

I've tried many compiler settings based on all other posts i could find but due to the embedded frameworks i need to support multiple architectures. None of the setting worked for me.

Also i tried to create another static framework and embed this into my 'parent' dynamic framework. I check this with lipo and the architecture seems to be added, but i still get the same undefined symbols error.

I am working on this for 2 days already so i really hope someone can point me in the right direction

UPDATE

Adding the flag "-undefined dynamic_lookup" solved the compile issue. However when adding the dynamic framework in a unity project it crashes when the method "UnitySendMessage" is triggered.

dyld`dyld_fatal_error:

*When creating a static framework the method doesn't crash and works fine. Still don't understand what's the difference in this case with a dynamic framework.

The method is declared in my .h file as followed:

#ifdef __cplusplus
extern "C" {
    void UnitySendMessage(const char* obj, const char* method, const char* msg);
}
#endif

回答1:

Make sure that the framework target in Build settings Build active architecture only = NO

if you are using cocoapod for managing your dependencies check pod target and put the Build active architecture only = NO