objc4-841.13可调试/编译源码更新
2022-06-20 本文已影响0人
erlich
心心念念查看了下objc4源码 https://opensource.apple.com/releases/ ,果然更新了,果断编译调试
如果想最省时省力,直接 github 下载可编译源码
下面开始配置可编译环境(本次配置为M1)
首先确保下载到841.13源码
首先编译target objc
- unable to find sdk 'macosx.internal'
image.png
-
PROJECTS–>objc–>Build Settings, 将Base SDK改成macOS -
TARGETS–>objc–>Build Settings, 将Base SDK改成macOS
- 'sys/reson.h' file not found
image.png
- 下载xnu-8020.101.4, 把
xnu-8020.101.4/bsd/sys/reason.h文件复制到comm_ifl/sys目录下
image.png
- 设置头文件搜索路径:
TARGETS–>objc–>Build Settings–>Header Search Paths, 添加一条$(SRCROOT)/comm_ifl
image.png
- 'mach-o/dyld_priv.h' file not found
image.png
- 下载 dyld-955, 把
dyld-955/include/mach-o/dyld_priv.h拷贝到comm_ifl/mach-o/dyld_priv.h
image.png
- 'os/lock_private.h' file not found
image.png
- 下载 libplatform-273.100.5, 把
libplatform-273.100.5/private/os/lock_private.h拷贝到comm_ifl/os/lock_private.h
image.png
- extern dyld_platform_t dyld_get_active_platform(void) __API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0), bridgeos(3.0)); ---- 报错 Expected ','
image.png
- 由于调试主要基于macos,删除
, bridgeos(3.0)
- 批量同5
image.png
- 同样均删除掉
, bridgeos(3.0)
- 'os/base_private.h' file not found
image.png
- 下载源码(macOS Catalina 10.15 - macOS 10.15.6)libplatform-220.100.1, 把
libplatform-220.100.1/private/os/base_private拷贝到comm_ifl/os/base_private.h
image.png
- 'pthread/tsd_private.h' file not found
- 下载 libpthread-libpthread-486.100.11
libpthread-libpthread-486.100.11/private/pthread/tsd_private.h拷贝到comm_ifl/pthread/tsd_private.h
- 'System/machine/cpu_capabilities.h' file not found
-
xnu-xnu-8020.101.4/osfmk/machine/cpu_capabilities.h拷贝到comm_ifl/System/machine/cpu_capabilities.h
- 'os/feature_private.h' file not found
- 注释掉
- 'os/variant_private.h' file not found
-
google搜索 os/variant_private.h opensource.apple.com
得到结果 https://opensource.apple.com/source/Libc/Libc-1244.50.9/os/variant_private.h.auto.html 根据路径找文件
-
拷贝
Libc-Libc-1507.100.9/os/variant_private.h至comm_ifl/os/variant_private.h
- 'os/tsd.h' file not found
- 拷贝
xnu-xnu-8020.101.4/libsyscall/os/tsd.h至comm_ifl/os/tsd.h
- 'pthread/spinlock_private.h' file not found
- 拷贝
libpthread-libpthread-486.100.11/private/pthread/spinlock_private.h至comm_ifl/pthread/spinlock_private.h
- 'System/pthread_machdep.h' file not found
- 拷贝
Libc-825.24/pthreads/pthread_machdep.h至comm_ifl/System/pthread_machdep.h
- bridgeos(4.0) 问题
- 去除
image.png
- 'CrashReporterClient.h' file not found
- 拷贝
Libc-825.24/include/CrashReporterClient.h至comm_ifl/CrashReporterClient.h
- Typedef redefinition with different types ('int' vs 'volatile OSSpinLock' (aka 'volatile int'))
image.png
- 注释掉
image.png
image.png
- Use of undeclared identifier 'dyld_platform_version_macOS_10_13'
image.png
- 注释
image.png
- 'os/bsd.h' file not found
- 注释
- 'os/reason_private.h' file not found
- 拷贝
xnu-xnu-8020.101.4/libkern/os/reason_private.h至comm_ifl/os/reason_private.h
- 'objc-shared-cache.h' file not found
- 拷贝
dyld-dyld-955/include/objc-shared-cache.h至comm_ifl/objc-shared-cache.h
- 'os/linker_set.h' file not found
- 拷贝
Libc-Libc-1507.100.9/os/linker_set.h至comm_ifl/os/linker_set.h
- '_simple.h' file not found
- 拷贝
Libc-825.24/gen/_simple.h至comm_ifl/_simple.h
- dyld_program_sdk_at_least(dyld_fall_2020_os_versions)
image.png
- 注释掉
image.png
- Use of undeclared identifier 'objc4'
- 注释掉
- Use of undeclared identifier 'CRGetCrashLogMessage'
image.png
image.png
- 'Cambria/Traps.h Cambria/Cambria.h' file not found
- 注释
- 'kern/restartable.h' file not found
-
xnu-xnu-8020.101.4/osfmk/kern/restartable.h拷贝到comm_ifl/kern/restartable.h
- Use of undeclared identifier 'oah_is_current_process_translated'
image.png
image.png
- Block_private.h
-
libclosure-libclosure-79.1/Block_private.h拷贝到comm_ifl/Block_private.h
- Use of undeclared identifier 'os_parse_boot_arg_string'
- 注释掉
image.png
- Use of undeclared identifier 'dyld_platform_version_macOS_10_11'
image.png
image.png
- Use of undeclared identifier 'dyld_fall_2018_os_versions'
- 注释掉
image.png
- Use of undeclared identifier 'dyld_platform_version_macOS_10_12'
image.png
image.png
- '_static_assert' declared as an array with a negative size
image.png
- 注释
在 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
CrashReporterClient异常
image.png
配置脚本
image.png
image.png
ld -loah报错
image.png
image.png
image.png
objc编译成功
image.png
接下来objc进行编译调试
-
新建target
image.png
-
建立依赖
image.png
image.png
编译调试target
image.png
-
下符号 alloc调试
image.png
进入源码 alloc
坚持到这一步,M1 objc调试环境OK,就恭喜了
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png