前期需要的源碼以及文件都能在Apple Open Source下載到
注意????
下面第九個文件需要在Libc-583下載
下面第十個文件需要在Libc-825.24下載
1.objc4-818.2
2.xnu-7195.60.75/bsd/sys/reason.h
3.dyld-832.7.1/include/mach-o/dyld_priv.h
4.libplatform-254.60.1/private/os/lock_private.h
5.libpthread-454.60.1/private/pthread/tsd_private.h
6.xnu-7195.60.75/osfmk/machine/cpu_capabilities.h
7.xnu-7195.60.75/libsyscall/os/tsd.h
8.libpthread-454.60.1/private/pthread/spinlock_private.h
9.Libc-583/pthreads/pthread_machdep.h
10.Libc-825.24/include/CrashReporterClient.h
11.dyld-832.7.1/include/objc-shared-cache.h
12.libplatform-254.60.1/private/_simple.h
13.libclosure-78/Block_private.h
14.xnu-7195.60.75/osfmk/kern/restartable.h
15.xnu-7195.60.75/libkern/os/base_private.h
首先運行起來會有如下報錯
修改如下圖
選擇target
->objc
-->Build Phases
-->Run Script(markgc)
把腳本文本macosx.internal
改成macosx
前期好的文件如下所示
接下來是第一個報錯如下
- 創(chuàng)建一個文件夾
Common
在工程根目錄下,再按如下配置好搜索路徑
image.png -
把前期下載好的文件按照如下
image.png
還有缺少的文件報錯如下
'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安全芯片使用的嵌入式操作系統(tǒng), 而在這里我們用不到這個系統(tǒng)所以刪掉,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
image.png
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 編譯調(diào)試
- 新建一個 Target : LBTest
-
綁定二進(jìn)制依賴關(guān)系
image.png
最后注意無法進(jìn)入到源碼斷點中,需要完成以下兩步
- 找到
LBTest
->Build Settings
->Enable Hardended Runtime
筋粗,將其設(shè)置為No
- 確保編譯源文件中
main.h
是第一個
image.png