Clang: Undefined symbols, but it is there using nm.

https://stackoverflow.com/questions/36662920/xcode-clang-link-build-dynamic-framework-or-dylib-not-embed-dependencies

clang use ld command to make the final link, I checked the manual and found -U and -undefinedcan ignore undefined symbols.

-U symbol_name 

Specified that it is ok for symbol_name to have no definition. With two_levelnamespace, the resulting symbol will be marked dynamic_lookup which means dyld will search all loaded images.

-undefined treatment

Specifies how undefined symbols are to be treated. Options are: error, warning, suppress, or dynamic_lookup. The default is error.

So the final solution is set -Wl,-undefined,dynamic_lookup to OTHER_LDFLAGS, also make sure search path set correctly. It works.

原文地址:https://www.cnblogs.com/lilei9110/p/6179585.html