1. otool -L,file xxx
>> otool -L /usr/local/Cellar/libftdi/1.4_2/lib/libftdi1.2.4.0.dylib
/usr/local/Cellar/libftdi/1.4_2/lib/libftdi1.2.4.0.dylib:
/usr/local/opt/libftdi/lib/libftdi1.2.dylib (compatibility version 2.0.0, current version 2.4.0)
/usr/local/opt/libusb/lib/libusb-1.0.0.dylib (compatibility version 3.0.0, current version 3.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.0.0)
YingXi:~ jerry.yang$ otool -L /usr/lib/libSystem.B.dylib
>> file /usr/lib/libobjc.dylib
/usr/lib/libobjc.dylib: Mach-O universal binary with 3 architectures
/usr/lib/libobjc.dylib (for architecture i386): Mach-O dynamically linked shared library i386
/usr/lib/libobjc.dylib (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64
/usr/lib/libobjc.dylib (for architecture x86_64h): Mach-O 64-bit dynamically linked shared library x86_64
2.<mach-o/dyld.h>中的NSVersionOfRunTimeLibrary(源代码见http://www.opensource.apple.com/source/dyld/dyld-132.13/src/dyldAPIsInLibSystem.cpp)
自己写个小工具,code如下:
#include <stdio.h>
#include <mach-o/dyld.h>
int main (int argc, char **argv)
{
printf ("%x\n", NSVersionOfRunTimeLibrary (argv[1]));
return 0;
}
编译好后,在终端中运行如下:
>> DYLD_INSERT_LIBRARIES=/usr/lib/libpam.2.dylib 编译生成的命令行工具 libpam.2.dylib
30000
dyld加载运行dylib的过程可参考(https://zhuanlan.zhihu.com/p/24875905):Source Browserhttps://opensource.apple.com/tarballs/dyld/ 3. oc @class 关键字,一般用在.h中,效果上是一种简化的import
@class:只引用class的定义成员变量、属性。等实现文件(.m/.mm等)中真正需要的时候,才会真正查看B类中的信息。
#import方式会包含被引用类的所有信息,包括被引用类的变量和方法;
即效果看起来是“.h文件中使用了@class xxx,而在.m文件中就要使用import引入实体”