Two projects:
dym -> dym.framework
hello -> hello.app
hello.app dynamic link dym.framework
The xcode settings for dynamic links have the following variables:
@rpath
In the hello project, the value of Run Path search paths has the following basic format:
//:configuration = Debug
LD_RUNPATH_SEARCH_PATHS = $(inherited) @loader_path/Frameworks @executable_path/Frameworks
//:configuration = Release
LD_RUNPATH_SEARCH_PATHS = $(inherited) @loader_path/Frameworks @executable_path/Frameworks
@loader_path
According to the analysis of apple doc, the directory where the binary file of the shared library is loaded is used
For example, hello.app/hello will load dym.framework/dym, then @loader_path points to the hello.app directory
@executable_path
According to the directory where the executable file in the app package is located;
The dym project needs to be set up:
Dynamic Library Install Name Base: @rpath
In this way, Dynamic Library install Name, default settings
$(DYLIB_INSTALL_NAME_BASE:standardizepath)/$(EXECUTABLE_PATH)
It will be displayed as
@rpath/dym.framework/dym
Then, the corresponding install name information will be saved in the dynamic library file generated by compilation
To set up the hello project, you only need to set Run Path search paths. After compilation is completed, the path parameter information will be saved to the RPATH of the hello target file. When the program is running, it will be under the path specified by RPATH. , find the install name of the dynamic library; for how rpath is generated in the compiler, you can refer to here.
When opened with dlopen, the dynamic library will be searched according to the path specified by @rapth. It can be opened using the following format:
dlopen(“./dym.framework/dym”, RTLD_LAZY);
Two projects:
dym -> dym.framework
hello -> hello.app
hello.app dynamic link dym.framework
The xcode settings for dynamic links have the following variables:
@rpath
In the hello project, the value of Run Path search paths has the following basic format:
//:configuration = Debug
LD_RUNPATH_SEARCH_PATHS = $(inherited) @loader_path/Frameworks @executable_path/Frameworks
//:configuration = Release
LD_RUNPATH_SEARCH_PATHS = $(inherited) @loader_path/Frameworks @executable_path/Frameworks
@loader_path
According to the analysis of apple doc, the directory where the binary file of the shared library is loaded is used
For example, hello.app/hello will load dym.framework/dym, then @loader_path points to the hello.app directory
@executable_path
According to the directory where the executable file in the app package is located;
The dym project needs to be set up:
Dynamic Library Install Name Base: @rpath
In this way, Dynamic Library install Name, default settings
$(DYLIB_INSTALL_NAME_BASE:standardizepath)/$(EXECUTABLE_PATH)
It will be displayed as
@rpath/dym.framework/dym
Then, the corresponding install name information will be saved in the dynamic library file generated by compilation
To set up the hello project, you only need to set Run Path search paths. After compilation is completed, the path parameter information will be saved to the RPATH of the hello target file. When the program is running, it will be under the path specified by RPATH. , find the install name of the dynamic library; for how rpath is generated in the compiler, you can refer to here.
When opened with dlopen, the dynamic library will be searched according to the path specified by @rapth. It can be opened using the following format:
dlopen(“./dym.framework/dym”, RTLD_LAZY);
Your framework should be included in the app. Then use the [NSBundle mainBundle] pathForResource series of functions to get the path.