- AutoRelease Pool 自动开释池
心心念念查看了下objc4源码 opensource.apple.com/releases/ ,果然更新了,果断编译调试
假如想最省时省力,直接 github 下载可编译源码
下面开端配置可编译环境(本次配置为M1)
首要保证下载到841.13源码
首要编译target objc
- unable to find sdk ‘macosx.internal’
-
PROJECTS
–>objc
–>BuildSettings
, 将BaseSDK
改成macOS
-
TARGETS
–>objc
–>BuildSettings
, 将BaseSDK
改成macOS
- ‘sys/reson.h’ file not found
- 下载xnu-8020.101.4, 把
xnu-8020.101.4/bsd/sys/reason.h
文件复制到comm_ifl/sys
目录下
- 设置头文件搜索途径:
TARGETS
–>objc
–>BuildSettings
–>HeaderSearchPaths
, 添加一条$(SRCROOT)/comm_ifl
- ‘mach-o/dyld_priv.h’ file not found
- 下载 dyld-955, 把
dyld-955/include/mach-o/dyld_priv.h
复制到comm_ifl/mach-o/dyld_priv.h
- ‘os/lock_private.h’ file not found
- 下载 libplatform-273.100.5, 把
libplatform-273.100.5/private/os/lock_private.h
复制到comm_ifl/os/lock_private.h
- 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 ‘,’
- 因为调试首要依据macos,删去
, bridgeos(3.0)
- 同5
- 相同均删去掉
, bridgeos(3.0)
- ‘os/base_private.h’ file not found
- 下载源码(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
- ‘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
得到成果 opensource.apple.com/source/Libc… 依据途径找文件
-
复制
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) 问题
- 去除
- ‘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’))
- 注释掉
- Use of undeclared identifier ‘dyld_platform_version_macOS_10_13’
- 注释
- ‘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)
- 注释掉
- Use of undeclared identifier ‘objc4’
- 注释掉
- Use of undeclared identifier ‘CRGetCrashLogMessage’
- ‘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’
- Block_private.h
-
libclosure-libclosure-79.1/Block_private.h
复制到comm_ifl/Block_private.h
- Use of undeclared identifier ‘os_parse_boot_arg_string’
- 注释掉
- Use of undeclared identifier ‘dyld_platform_version_macOS_10_11’
- Use of undeclared identifier ‘dyld_fall_2018_os_versions’
- 注释掉
- Use of undeclared identifier ‘dyld_platform_version_macOS_10_12’
- ‘_static_assert’ declared as an array with a negative size
- 注释
在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异常
CrashReporterClient.h现已导入,仍是报错 找不到
配置脚本
ld -loah报错
objc编译成功
接下来objc进行编译调试
- 新建target
- 树立依靠
编译调试target
- 下符号 alloc调试
进入源码 alloc
坚持到这一步,M1 objc调试环境OK,就恭喜了
- 自动开释池