preface
Objc4-818.2 has been unavailable since XCode was updated to macOC Monterey. Apple has recently updated the objC4-838 source code, so it can’t wait to compile it.
The preparatory work
-
- Download objC4-838 source code
-
- Download dyLD-940 source code
-
- Download libC-1506.40.4 source code
-
- Download libC-825.40.1 source code
-
- Download libclosure-79 source code
-
- Download libplatform-273.40.1 source code
-
- Download libplatform – 220.100.1
-
- Download libpthread-485.40.4
-
- Download xNU-8019-41.5 source code
Compile environment
MAC 2015
macOC Monterey
+Xcode 13
Pre-compile modification
Open objC4 project
1. Modify the script
-
Targets -> Run Script (markgc) change macosx.internal to macosx:
2. ModifyBase SDK
-
Go to Project -> Build Setting -> Base SDK and select macOS:
3. Select a compilation target
Compile and add missing libraries
-
Select Targets -> objc
-
Create a file called WSLib in the root directory of the project. Select Targets -> Build Settings -> Header Search Paths to configure the WSLib path:
-
Now compile and handle the error
1. 'sys/reason.h' file not found
-
In the BSD -> sys file of xnu-main, find reason.h and copy it. Create sys file in WSLib and paste reason.h file
-
Continue to compile
2. 'mach-o/dyld_priv.h' file not found
-
Find the dyLD_priv. h file in the directory include-> mach-o from dyld-main and copy it, then create the Mach-o file in WSLib and paste dyLD_priv. h
-
Open the dyLD_priv.h file and add the macro definition:
#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 Copy the code
-
Continue to compile
3. 'os/lock_private.h' file not found
-
In the downloaded source libplatform-main, private -> OS find the lock_private.h file and copy it, then create the OS file in WSLib and paste lock_private.h
-
Continue to compile
4. Expected ','
An error (dyld_priv.h
File)
-
Delete the bridgeos(3.0) parameter from the file where all errors were reported with the previous, :
-
After deletion, continue compiling
5. 'os/base_private.h' file not found
-
In libplatform-220.100.1, find the base_private.h file in the private -> OS directory, copy it, and paste it into the OS file in WSLib
-
Continue to compile
6. 'pthread/tsd_private.h' file not found
- An error is reported here
lock_private.h
In the file, there are two mistakes:- The first thing to do is get rid of the files
Bridgeos (4.0)
parameter - Second in the download
libpthread-main
Source code, in the directoryprivate
->pthread
Found in thetsd_private.h
And copy, and then inWSLib
Created in thepthread
Directory and paste the file
- The first thing to do is get rid of the files
- Continue to compile
7. 'System/machine/cpu_capabilities.h' file not found
-
In xnu-main, go to osfmk -> machine and find the cpu_capabilities. H file and copy it. Then create the System file in WSLib, and then create the machine file in the System file. And paste cpu_capabilities. H
-
Continue to compile
8.'os/tsd.h' file not found
-
In the downloaded source xnu-main, find tsd.h in the directory libsyscall -> OS and copy it, then paste it in the OS file in WSLib
-
Continue to compile
9. 'pthread/spinlock_private.h' file not found
-
In the downloaded source libpthread-main, find the spinlock_private.h file in the private -> pthread directory and copy it and paste it into the pthread file in WSLib
-
Continue to compile
10. 'System/pthread_machdep.h' file not found
-
In the downloaded file libC-825.40.1, find the pthread_machdep.h file in the directory pthreads and copy it and paste it into the WSLib -> System directory
-
Continue to compile
11. 'CrashReporterClient.h' file not found
-
In the downloaded file libC-825.40.1, find the crashReporterClient.h file and copy it, then paste it into the WSLib file
- There are two options:
-
- in
CrashReporterClient.h
To add macro definitions
#define LIBC_NO_LIBCRASHREPORTERCLIENT Copy the code
- in
-
- in
Targets
->objc
->Build Settings
->Preprocessor Macros
, addLIBC_NO_LIBCRASHREPORTERCLIENT
- in
-
- There are two options:
-
Continue to compile
12. The annotationdeclaration of
和 Typedef redefinition with
-
There are four errors reported in the pthread_machdep.h file
-
Typedef redefinition with different types ('int' vs 'volatile OSSpinLock' (aka 'volatile int'))
-
Static declaration of '_pthread_has_direct_tsd' follows non-static declaration
-
Static declaration of '_pthread_getspecific_direct' follows non-static declaration
-
Static declaration of '_pthread_setspecific_direct' follows non-static declaration
Comment out all of these errors
-
-
Continue to compile
13. 'os/feature_private.h' file not found
- Just comment it out
14. Use of undeclared identifier 'dyld_fall_2020_os_versions'
-
Comment out two lines of code that are relevant
15. Use of undeclared identifier 'objc4'
-
Comment out the relevant code
16. Use of undeclared identifier 'dyld_platform_version_macOS_10_13'
-
Comment out this code
17. Use of undeclared identifier 'dyld_platform_version_macOS_10_11'
-
Comment out relevant conditions
18. 'objc-shared-cache.h' file not found
-
In the downloaded source dyld-main, find objc-shared-cache.h in the directory include, copy it, and paste it into WSLib
-
Continue to compile
19. Use of undeclared identifier 'dyld_fall_2018_os_versions'
-
Annotation correlation condition
-
Continue to compile
20. '_simple.h' file not found
- Download the source code
libplatform-main
In theprivate
Find the directory and copy it, then paste it intoWSLib
In the
21. 'os/linker_set.h' file not found
- Download the source code
xnu-main
In the directorybsd
->sys
Found in thelinker_set.h
And copy toWSLib
In theos
directory
22. 'Cambria/Traps.h' file not found
-
Comment out code
#include <Cambria/Traps.h> #include <Cambria/Cambria.h> Copy the code
23. 'Block_private.h' file not found
- Download the source code
libclosure-main
Found in theBlock_private.h
And copy toWSLib
directory
25. 'kern/restartable.h' file not found
- Download the source code
xnu-main
In the directoryosfmk
->kern
Found in therestartable.h
File and copy, then inWSLib
Created in thekern
Directory and pasterestartable.h
file
26. oah_is_current_process_translated
withobjc_thread_get_rip
An error
-
Comment the condition
27. 'os/feature_private.h' file not found
- Comment a reference to the u-turn file
28. 'os/reason_private.h' file not found
- Download the source code
xnu-main
In the directorylibkern
->os
Found in thereason_private.h
File and paste intoWSLib
In theos
In the file
29. 'os/variant_private.h' file not found
-
Locate variant_private.h in the OS directory of the downloaded source code libc-main and copy it to the OS directory in WSLib
-
In variant_private.h, delete the bridgeos parameter
30. Use of undeclared identifier 'dyld_platform_version_bridgeOS_2_0'
-
Comment out this code
31. '_static_assert' declared as an array with a negative size
-
Comment out these two lines
32. library not found for -lCrashReporterClient
-
Choose Targets -> Build Setting -> Other Linker Flags and delete -lCrashReporterClient
33. library not found for -loah
-
Go to Targets -> Build Setting -> Other Linker Flags and delete -loah
Compiled successfully 🎉🎉🎉
addTarget
-
First click the + under Targets:
-
Then select macOS -> Command Line Tool, named WSBuild
-
Add dependency library libobjc.a.dylib:
compileWSBuild
(newTarget
)
-
Select WSBuild first:
Fix breakpoint stalling problem
-
- in
Build Phases
theCompile Sources
,main.m
Drag it to the front
- in
-
- find
Targets
->Build Settings
->Enable Hardened Runtime
And value forNO
- find
Once set, breakpoints are ready to go:
knownM1
Computer bug fix
- will
objc-cache.mm
Error code comment in:
Tips ✨
- In the source code
macOC Monterey
Runnable, lower thanmacOC Monterey
The system is availableObjc4-818.2 -Source code, need to compile. - Finally, a compiled Demo is attached