objc4-818.2 源碼下載地址: https://opensource.apple.com/tarballs/objc4/
- mac OS 10.15.6
- Xcode 12.2
- objc4-818.2
問(wèn)題1:unable to find sdk 'macosx.internal'
解決:選擇 target -> objc -> Build Settings -> Base SDK -> 選擇 macOS 【target中的 所有Target都應(yīng)將Base SDK 修改為macOS更改】
需要的支持庫(kù)文件
launchd-106.10 需要在Mac OS X 10.4.4下載惯豆,其他的均可以在最新的的版本macOS 10.15中現(xiàn)在
問(wèn)題2:工程目錄/objc4-818.2/runtime/objc-os.h:126:13: 'sys/reason.h' file not found
- xnu-6153.11.26/bsd/sys/文件夾下的reason.h ---> 拷貝到工程目錄/HTCommon/sys/目錄下
設(shè)置文件檢索路徑:選擇 target -> objc -> Build Settings姓赤,在工程的 Header Serach Paths 中添加搜索路徑 $(SRCROOT)/HTCommon
問(wèn)題3:工程目錄/objc4-818.2/runtime/objc-os.h:134:13: 'mach-o/dyld_priv.h' file not found
找到文件:dyld-732.8 /include/mach-o /dyld_priv.h -->拷貝到HTCommon/mach-o 文件夾下
拷貝到文件后橘荠,還需要修改 dyld_priv.h 文件别智,即在 dyld_priv.h文件頂部加入一下宏:
#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
bridgeos(4.0),bridgeos(3.0);如果報(bào)錯(cuò),去掉 bridgeos(3.0)和bridgeos(4.0)
問(wèn)題4: 'os/lock_private.h' file not found, 'os/base_private.h' file not found
libplatform-220/private/os/ 文件夾下的 lock_private.h 蒂秘、base_private.h拆融,拷貝到HTCommon/os/文件夾下
問(wèn)題5:'pthread/tsd_private.h' file not found 和 'pthread/spinlock_private.h' file not found
libpthread-416.11.1/ private文件夾下找到tsd_private.h、spinlock_private.h文件唁情,并拷貝到 HTCommon /pthread文件夾下
問(wèn)題6:'System/machine/cpu_capabilities.h' file not found
xnu-6153.11.26/osfmk/machine/找到cpu_capabilities.h文件疑苔,并拷貝到HTCommon/System /machine文件夾下
問(wèn)題7:'os/tsd.h' file not found
xnu-6153.11.26/ libsyscall /os/找到 tsd.h,并拷貝到HTCommon/os/文件夾下
問(wèn)題8 'System/pthread_machdep.h' file not found
找到pthread_machdep.h
甸鸟,將其拷貝至HTCommon/System文件中
在最新版的macOS 10.15中最新版下載的
libc
中沒(méi)有這個(gè)h文件惦费,需要下載Libc-583
版本
從結(jié)果發(fā)現(xiàn)我們之前引入的pthread_machdep.h已經(jīng)typedef過(guò)了。注釋掉其中一個(gè)就好抢韭。但我這里選擇注釋掉pthread_machdep.h的
typedef int pthread_lock_t;
_pthread_has_direct_tsd(void) 整個(gè)函數(shù)
_pthread_getspecific_direct(unsigned long slot) 整個(gè)函數(shù)
//typedef int pthread_lock_t;
問(wèn)題9 'CrashReporterClient.h' file not found
-
CrashReporterClient.h中找到該文件薪贫,路徑為
Libc-825.24/include/CrashReporterClient.h
,直接存放在HTCommon文件中 - 導(dǎo)入下載的還是報(bào)錯(cuò),可以通過(guò)以下方式解決
需要在 Build Settings -> Preprocessor Macros 中加入:LIBC_NO_LIBCRASHREPORTERCLIENT
如果還是報(bào)錯(cuò)
CrashReporterClient
的問(wèn)題刻恭,解決方法是 在BuildSetting --> Other Linker Flags
中去掉CrashReporterClient
.
問(wèn)題10 'objc-shared-cache.h' file not found
dyld-732.8/include/objc-shared-cache.h 拷貝到HTCommon
問(wèn)題11 #error mismatch in debug-ness macros
注釋掉此行
問(wèn)題12 '_simple.h' file not found
libplatform-220/private/文件夾下找到 _simple.h 瞧省,拷貝到HTCommon
問(wèn)題13 'kern/restartable.h' file not found
xnu-6153.11.26/osfmk/kern/文件夾下找到restartable.h,并拷貝到HTCommon/ kern 文件夾下
問(wèn)題14 'Block_private.h' file not found
libclosure-74/文件夾下找到Block_private.h鳍贾,拷貝到HTCommon文件夾下
問(wèn)題15 Static_assert failed due to requirement 'bucketsMask >= ((unsigned long long)140737454800896ULL)' "Bucket field doesn't have enough bits for arbitrary pointers."臀突, 直接注釋掉該斷言
問(wèn)題16 '_static_assert' declared as an array with a negative size--->直接注釋掉該斷言
問(wèn)題17 ld: can't open order file: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk/AppleInternal/OrderFiles/libobjc.order
解決方法是Project->Target->Build Settings->Order File添加路徑$(SRCROOT)/libobjc.order。
問(wèn)題18 Xcode 腳本編譯問(wèn)題
問(wèn)題描述為:/xcodebuild:1:1: SDK "macosx.internal" cannot be located.
選擇 target -> objc -> Build Phases -> Run Script(markgc)
把腳本文本 macosx.internal 改成 macosx
編譯調(diào)試
新建一個(gè)target :HTTest
綁定objc
源碼調(diào)試
-
自定義一個(gè)HTPerson類
image.png -
在main.m中 創(chuàng)建 HTPerson的對(duì)象贾漏,進(jìn)行源碼調(diào)試
image.png
創(chuàng)建的調(diào)試target中main的斷點(diǎn)無(wú)法斷住的問(wèn)題
Build Phases --> Compile Source中候学,將main文件移至第一位
Build Setting --> 將Enable Hardened Runtime 置為NO
image.png