獲取源碼
前往官方地址下載源碼庆锦,解壓并打開工程肠骆。這里有我已經(jīng)處理好的工程
創(chuàng)建調(diào)試 Target
創(chuàng)建一個(gè) command line target
命名為 objc-debug
添加依賴
將靜態(tài)庫(kù)工程 objc
添加為 objc-debug
的 Target Dependencies
箩退,在 Link Binary With Libraries
中添加 libobjc.A.dylib
解決編譯錯(cuò)誤
The i386 architecture is deprecated
將objc-debug
玉转、objc
和 objc-trampolines
中的 Build Settings
選項(xiàng) Architectures
中的值切換為 Standard Architectures(64-bit Intel)
'sys/reason.h' file not found
在工程目錄中創(chuàng)建 Common
文件夾爪模,在工程的 Header Serach Paths
中添加搜索路徑 $(SRCROOT)/Common
獲取頭文件
使用 Google 搜索reason.h site:opensource.apple.com
开镣,百度不行刀诬。由于reason.h
在sys
目錄下,所以在Common
目錄中創(chuàng)建sys
目錄邪财,并將reason.h
放入sys
目錄中陕壹,重新編譯。
以同樣的方式解決下列問題:
- 'mach-o/dyld_priv.h' file not found
- 'os/lock_private.h' file not found
- 'os/base_private.h' file not found
- 'pthread/tsd_private.h' file not found
- 'System/machine/cpu_capabilities.h' file not found
- 'os/tsd.h' file not found
- 'pthread/spinlock_private.h' file not found
- 'System/pthread_machdep.h' file not found
- 'objc-shared-cache.h' file not found
- '_simple.h' file not found
- 'Block_private.h' file not found
'CrashReporterClient.h' file not found
修改CrashReporterClient.h
添加 #define LIBC_NO_LIBCRASHREPORTERCLIENT
Can't open order file: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/AppleInternal/OrderFiles/libobjc.order
在Order File
中添加$(SRCROOT)/libobjc.order
Library not found for -lCrashReporterClient
在Other Linker Flags
中刪除-lCrashReporterClient
SDK "macosx.internal" cannot be located.
unable to find utility "clang++", not a developer tool or in PATH
將Target objc
的Build Phases->Run Script(markgc)
里的內(nèi)容macosx.internal
改為macosx
no such public header file: '/tmp/objc.dst/usr/include/objc/ObjectiveC.apinotes'
把Text-Based InstallAPI Verification Model
里的值改為Errors Only
清空 Other Text-Based InstallAPI Flags
中的值
編譯成功
處理完以上錯(cuò)誤后树埠,編譯即可成功糠馆。可以在 objc-debug
的 main.m
中添加代碼怎憋,進(jìn)行調(diào)試了又碌。
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSObject *obj = [NSObject new];
NSLog(@"obj:%@", obj);
}
return 0;
}