- 前期需要的源码以及文件都能在Apple Open Source下载到
- 注意⚠️⚠️
- 下面第九个文件需要在Libc-583下载
- 下面第十个文件需要在Libc-825.24下载
objc4-818.2xnu-7195.60.75/bsd/sys/reason.hdyld-832.7.1/include/mach-o/dyld_priv.hlibplatform-254.60.1/private/os/lock_private.hlibpthread-454.60.1/private/pthread/tsd_private.hxnu-7195.60.75/osfmk/machine/cpu_capabilities.hxnu-7195.60.75/libsyscall/os/tsd.hlibpthread-454.60.1/private/pthread/spinlock_private.hLibc-583/pthreads/pthread_machdep.hLibc-825.24/include/CrashReporterClient.hdyld-832.7.1/include/objc-shared-cache.hlibplatform-254.60.1/private/_simple.hlibclosure-78/Block_private.hxnu-7195.60.75/osfmk/kern/restartable.hxnu-7195.60.75/libkern/os/base_private.h
首先运行起来会有如下报错
修改如下图
选择target->objc-->Build Phases-->Run Script(markgc)把脚本文本macosx.internal改成macosx
前期好的文件如下所示
接下来是第一个报错如下
- 创建一个文件夹
Common在工程根目录下,再按如下配置好搜索路径 - 把前期下载好的文件按照如下
还有缺少的文件报错如下
'sys/reason.h' file not found 'mach-o/dyld_priv.h' file not found 'os/lock_private.h' file not found 'os/base_private.h' file not found 'pthread/tsd_private.h' file not found 'System/machine/cpu_capabilities.h' file not found 'os/tsd.h' file not found 'pthread/spinlock_private.h' file not found 'System/pthread_machdep.h' file not found 'CrashReporterClient.h' file not found 'objc-shared-cache.h' file not found '_simple.h' file not found 'Block_private.h' file not found 'kern/restartable.h' file not found
这个os/dyld.priv.h和os/lock_private.h文件中报错如下,是因为Bridge OS是Apple独立的T2安全芯片使用的嵌入式操作系统, 而在这里我们用不到这个系统所以删掉,bridgeos(3.0)和,bridgeos(4.0)即可
CrashReporterClient.h报错如下,需要在Build Settings -> Preprocessor Macros 中加入:LIBC_NO_LIBCRASHREPORTERCLIENT
需要注释的代码如下
#接下来是libobjc.order 路径问题
can't open order file:/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/AppleInternal/OrderFiles/libobjc.order
- 选择
target->objc->Build Settings - 在工程的
Order File中添加路径$(SRCROOT)/libobjc.order#lCrashReporterClient 编译不到
library not found for -lCrashReporterClient
- 选择
target->objc->Build Settings - 在
Other Linker Flags中删除-lCrashReporterClient( Debug 和 Release 都删了)
#library not found for -loah
- 选择
target->objc->Build Settings - 在
Other Linker Flags中删除-loah( Debug 和 Release 都删了)
编译成功
objc 编译调试
- 新建一个 Target : LBTest
- 绑定二进制依赖关系
#最后注意无法进入到源码断点中,需要完成以下两步
- 找到
LBTest->Build Settings->Enable Hardended Runtime,将其设置为No - 确保编译源文件中
main.h是第一个