Ios_objc4-818.2 Compile and debug the latest source code
Many small partners in the exploration of the bottom is often very distressed, can only rely on speculation! A little bit more flexible friends will be provided by Apple source code to help look at it, but obviously this is not too intuitive! If you can directly compile debugging, like our own code directly LLDB debugging, process tracking. That wasn’t too cool, so I compiled the current version of iOS_OBJC4-818.2.
I. Preparation
- Xcode 12.4
- Download the objC source
- Open the downloaded source code
2. Start the configuration
1. Problem: macOS version processing
Solution: Modify the source compilation environment
macOS
2. Problem: I386 architecture problem
Solution: Will
objc和objc-trampolinesIn theBuild SettingsoptionsArchitecturesIs switched toStandard Architectures(64-bit Intel)
3. Problem: Document checking and filling
'sys/reason. H' file not found
Solution: Add the missing file
- Through Gitee source download, path in objc4-818.2 / ZLCommon/sys/reason. H to download
- Add the found files to the project. Such as:
- The root directory creates one
ZLCommonfolder- create
sysfolder- the
reason.hFile in- Path for retrieving configuration files. As follows:
- choose
target->objc->Build Settings- In the engineering of
Header Serach PathsTo add a search path$(SRCROOT)/ZLCommon.
'mach-o/dyld_priv.h' file not found
'os/lock_private.h' file not found
'os/base_private.h' file not found
'os/tsd.h' file not found
'pthread/tsd_private.h' file not found
'pthread/spinlock_private.h' file not found
'System/machine/cpu_capabilities.h' file not found
'System/pthread_machdep.h' file not found
'CrashReporterClient.h' file not found
'objc-shared-cache.h' file not found
'_simple.h' file not found
'Block_private.h' file not found
The above error cases are handled in the same way, and will not be described here.
Note: If you do not have the required file, there are two ways to handle it:
- Just comment it out, for example:
'os/feature_private.h' file not found- toApple SourceDownload the latest
xnuThe package. However, this way is not very convenient, we do not know the missing file belongs to which library, it is recommended to download the source file provided by the small series to import, other if the error is directly commented out.
4. Problem: CrashReporterClient
'CrashReporterClient.h' file not found
Solution: Need in
Build Settings->Preprocessor MacrosAdd:LIBC_NO_LIBCRASHREPORTERCLIENT
5. Problem: The _static_assert exception occurs
'_static_assert' declared as an array with a negative size
Solution: Just comment it out
6. Problem: Libobjc. Order path problem
Solution:
- choose
target->objc->Build Settings- In the engineering of
Order FileTo add a search path$(SRCROOT)/libobjc.order
7. Problem: lCrashReporterClient cannot be compiled
Library not found for -lCrashReporterClient
Solution:
- choose
target->objc->Build Settings- in
Other Linker FlagsRemove the-lCrashReporterClient(Debug和ReleaseHave deleted)- If there is
Library not found for -loahError, handling manner consistent.
8. Problem: Xcode script compilation problem
`/xcodebuild:1:1: SDK “macosx.internal” cannot be located.
Solution:
- choose
target->objc->Build Settings->Run Script(markgc)- Put the script text
macosx.internaltomacosx
9. Problem: ObjectiveC. Apinotes is abnormal
no such public header file: '/tmp/objc.dst/usr/include/objc/ObjectiveC.apinotes'
Solution:
- choose
target->objc->Build SettingsText-Based InstallAPI Verification ModelTo add a search pathErrors OnlyOther Text-Based InstallAPI FlagsClear everything
10. Problem: _objC_opt_class cannot be compiled
Undefined symbol: _objc_opt_class
Solution:
This problem is due to the new MacOS 10.15, because at the time of writing, there is no official release yet! Here we are backwards compatible with MacOS 10.14
Compile and debug
1. Create oneTarget
2. Bind dependencies
3. main.mIt has to come first
And that’s it. If there’s nothing wrong with it, you can compile it.