• AutoRelease Pool 自动开释池

心心念念查看了下objc4源码 opensource.apple.com/releases/ ,果然更新了,果断编译调试

假如想最省时省力,直接 github 下载可编译源码

下面开端配置可编译环境(本次配置为M1)

首要保证下载到841.13源码

首要编译target objc

  1. unable to find sdk ‘macosx.internal’

objc4-841.13可调试/编译源码更新(for M1)

  • PROJECTS–>objc–>BuildSettings, 将BaseSDK改成macOS
  • TARGETS–>objc–>BuildSettings, 将BaseSDK改成macOS
  1. ‘sys/reson.h’ file not found

objc4-841.13可调试/编译源码更新(for M1)

  • 下载xnu-8020.101.4, 把xnu-8020.101.4/bsd/sys/reason.h文件复制到comm_ifl/sys目录下

objc4-841.13可调试/编译源码更新(for M1)

  • 设置头文件搜索途径:TARGETS–>objc–>BuildSettings–>HeaderSearchPaths, 添加一条$(SRCROOT)/comm_ifl

objc4-841.13可调试/编译源码更新(for M1)

  1. ‘mach-o/dyld_priv.h’ file not found

objc4-841.13可调试/编译源码更新(for M1)

  • 下载 dyld-955, 把 dyld-955/include/mach-o/dyld_priv.h 复制到 comm_ifl/mach-o/dyld_priv.h

objc4-841.13可调试/编译源码更新(for M1)

  1. ‘os/lock_private.h’ file not found

objc4-841.13可调试/编译源码更新(for M1)

  • 下载 libplatform-273.100.5, 把 libplatform-273.100.5/private/os/lock_private.h 复制到 comm_ifl/os/lock_private.h

objc4-841.13可调试/编译源码更新(for M1)

  1. 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 ‘,’

objc4-841.13可调试/编译源码更新(for M1)

  • 因为调试首要依据macos,删去, bridgeos(3.0)
  1. 同5

objc4-841.13可调试/编译源码更新(for M1)

  • 相同均删去掉 , bridgeos(3.0)
  1. ‘os/base_private.h’ file not found

objc4-841.13可调试/编译源码更新(for M1)

  • 下载源码(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

objc4-841.13可调试/编译源码更新(for M1)

  1. ‘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
  1. ‘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
  1. ‘os/feature_private.h’ file not found
  • 注释掉
  1. ‘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.hcomm_ifl/os/variant_private.h

  1. ‘os/tsd.h’ file not found
  • 复制 xnu-xnu-8020.101.4/libsyscall/os/tsd.hcomm_ifl/os/tsd.h
  1. ‘pthread/spinlock_private.h’ file not found
  • 复制 libpthread-libpthread-486.100.11/private/pthread/spinlock_private.hcomm_ifl/pthread/spinlock_private.h
  1. ‘System/pthread_machdep.h’ file not found
  • 复制 Libc-825.24/pthreads/pthread_machdep.hcomm_ifl/System/pthread_machdep.h
  1. bridgeos(4.0) 问题
  • 去除

objc4-841.13可调试/编译源码更新(for M1)

  1. ‘CrashReporterClient.h’ file not found
  • 复制 Libc-825.24/include/CrashReporterClient.hcomm_ifl/CrashReporterClient.h
  1. Typedef redefinition with different types (‘int’ vs ‘volatile OSSpinLock’ (aka ‘volatile int’))

objc4-841.13可调试/编译源码更新(for M1)

  • 注释掉

objc4-841.13可调试/编译源码更新(for M1)
objc4-841.13可调试/编译源码更新(for M1)

  1. Use of undeclared identifier ‘dyld_platform_version_macOS_10_13’

objc4-841.13可调试/编译源码更新(for M1)

  • 注释

objc4-841.13可调试/编译源码更新(for M1)

  1. ‘os/bsd.h’ file not found
  • 注释
  1. ‘os/reason_private.h’ file not found
  • 复制 xnu-xnu-8020.101.4/libkern/os/reason_private.hcomm_ifl/os/reason_private.h
  1. ‘objc-shared-cache.h’ file not found
  • 复制 dyld-dyld-955/include/objc-shared-cache.hcomm_ifl/objc-shared-cache.h
  1. ‘os/linker_set.h’ file not found
  • 复制 Libc-Libc-1507.100.9/os/linker_set.hcomm_ifl/os/linker_set.h
  1. ‘_simple.h’ file not found
  • 复制 Libc-825.24/gen/_simple.hcomm_ifl/_simple.h
  1. dyld_program_sdk_at_least(dyld_fall_2020_os_versions)

objc4-841.13可调试/编译源码更新(for M1)

  • 注释掉

objc4-841.13可调试/编译源码更新(for M1)

  1. Use of undeclared identifier ‘objc4’
  • 注释掉
  1. Use of undeclared identifier ‘CRGetCrashLogMessage’

objc4-841.13可调试/编译源码更新(for M1)
objc4-841.13可调试/编译源码更新(for M1)

  1. ‘Cambria/Traps.h Cambria/Cambria.h’ file not found
  • 注释
  1. ‘kern/restartable.h’ file not found
  • xnu-xnu-8020.101.4/osfmk/kern/restartable.h 复制到 comm_ifl/kern/restartable.h
  1. Use of undeclared identifier ‘oah_is_current_process_translated’

objc4-841.13可调试/编译源码更新(for M1)
objc4-841.13可调试/编译源码更新(for M1)

  1. Block_private.h
  • libclosure-libclosure-79.1/Block_private.h 复制到 comm_ifl/Block_private.h
  1. Use of undeclared identifier ‘os_parse_boot_arg_string’
  • 注释掉

objc4-841.13可调试/编译源码更新(for M1)

  1. Use of undeclared identifier ‘dyld_platform_version_macOS_10_11’

objc4-841.13可调试/编译源码更新(for M1)
objc4-841.13可调试/编译源码更新(for M1)

  1. Use of undeclared identifier ‘dyld_fall_2018_os_versions’
  • 注释掉

objc4-841.13可调试/编译源码更新(for M1)

  1. Use of undeclared identifier ‘dyld_platform_version_macOS_10_12’

objc4-841.13可调试/编译源码更新(for M1)
objc4-841.13可调试/编译源码更新(for M1)

  1. ‘_static_assert’ declared as an array with a negative size

objc4-841.13可调试/编译源码更新(for M1)

  • 注释

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现已导入,仍是报错 找不到

配置脚本

objc4-841.13可调试/编译源码更新(for M1)

objc4-841.13可调试/编译源码更新(for M1)

objc4-841.13可调试/编译源码更新(for M1)

ld -loah报错

objc4-841.13可调试/编译源码更新(for M1)

objc4-841.13可调试/编译源码更新(for M1)

objc4-841.13可调试/编译源码更新(for M1)

objc编译成功

objc4-841.13可调试/编译源码更新(for M1)

接下来objc进行编译调试

  • 新建target

objc4-841.13可调试/编译源码更新(for M1)

  • 树立依靠

objc4-841.13可调试/编译源码更新(for M1)

objc4-841.13可调试/编译源码更新(for M1)

编译调试target

objc4-841.13可调试/编译源码更新(for M1)

  • 下符号 alloc调试

objc4-841.13可调试/编译源码更新(for M1)

进入源码 alloc

坚持到这一步,M1 objc调试环境OK,就恭喜了

  • 自动开释池