Xcode clang link: Build Dynamic Framework (or dylib) does not embed dependencies

I am creating a dynamic framework for iOS. It is necessary to refer to some characters from the code or other libraries, but I do not want to associate them with the framework.

This can be achieved by creating a static library, just set the search path and make sure that they are not included in the phases of the build goals.

But when building a dynamic structure or dylib, this result is an undefined character error. I tried all kinds of links, for example -l -weak_library -weak_framework -I -rpath -rpath-link . But no one is working.

The link command looks like this:

 clang -arch x86_64 -dynamiclib -isysroot *iPhone_SDK_PATH* *OPTIONS_NOT_IMPORTANT* -install_name @rpath/Foo.framework/Foo -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -Xlinker -rpath -Xlinker *BUILD_PATH* -mios-simulator-version-min=7.0 -Xlinker -no_deduplicate -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -fobjc-link-runtime -framework Foundation -single_module -compatibility_version 1 -current_version 1 -Xlinker -dependency_info -Xlinker *BUILD_PATH*/Foo.build/Objects-normal/x86_64/Foo_dependency_info.dat -o *BUILD_PATH*/Foo.framework/Foo 
0
source share
1 answer

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

-U symbol_name

It is indicated that for character_name there is no definition. With two_levelnamespace, the resulting character will be marked as dynamic_lookup, which means that dyld will search for all uploaded images.

- undefined treatment

Specifies how to handle undefined characters. Possible options are error, warning, suppression, or dynamic_lookup. The default is error.

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

0
source

Source: https://habr.com/ru/post/948009/


All Articles