调试objc4源码并编译

iOS底层探究-02:objc4-781源码编译&调试

2020-09-07  本文已影响0人  对你的微笑纯属礼貌_e31

学会编译objc4-781的源码,然后在源码中进行调试,便于探究底层的实现流程

准备工作

环境版本 & 最新objc源码
依赖文件下载

需要下载以下依赖文件


1.png

源码编译

编译源码就是不断调试的过程,主要有以下问题:

问题一:unable to find sdk 'macosx.internal'
2.png
问题二:文件找不到的报错问题
1、'sys/reason.h' file not found
5.png 3.png
2、'mach-o/dyld_priv.h' file not found
6.png
#define DYLD_MACOSX_VERSION_10_11 0x000A0B00
#define DYLD_MACOSX_VERSION_10_12 0x000A0C00
#define DYLD_MACOSX_VERSION_10_13 0x000A0D00
#define DYLD_MACOSX_VERSION_10_14 0x000A0E00
3、bridgeos(3.0)、bridgeos(4.0)报错
1.png
4、'os/lock_private.h' file not found 和 'os/base_private.h' file not found
2.png
5、'pthread/tsd_private.h' file 和 'pthread/spinlock_private.h' file not found
6、'System/machine/cpu_capabilities.h' file not found
4.png

在之前准备的依赖文件中全局搜索cpu_capabilities.h文件(选择此路径下的xnu-6153.141.1/osfmk/machine),并将文件拷贝至 machine文件中

7、'os/tsd.h' file not found
8、'System/pthread_machdep.h' file not found

在最新版的macOS 10.15中最新版下载的libc中没有这个h文件,需要下载Libc-583版本

9、'CrashReporterClient.h' file not found
10、'objc-shared-cache.h' file not found
11、'_simple.h' file not found
12、'kern/restartable.h' file not found
13、'Block_private.h' file not found
14、libobjc.order 路径问题

ld: can't open order file: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/AppleInternal/OrderFiles/libobjc.order

15、library not found -lCrashReporterClient
2.png
16、Xcode 脚本编译问题

问题:Showing All Messages /xcodebuild:1:1: SDK "macosx.internal" cannot be located.

编译调试

源码调试

上一篇 下一篇

猜你喜欢

热点阅读