objc4-756.2 编译

获取源码

前往官方地址下载源码,解压并打开工程。这里有我已经处理好的工程

创建调试 Target

创建一个 command line target 命名为 objc-debug

objc-debug

添加依赖

将静态库工程 objc 添加为 objc-debugTarget Dependencies,在 Link Binary With Libraries 中添加 libobjc.A.dylib

依赖

解决编译错误

The i386 architecture is deprecated

objc-debugobjcobjc-trampolines中的 Build Settings选项 Architectures中的值切换为 Standard Architectures(64-bit Intel)

i386

'sys/reason.h' file not found

在工程目录中创建 Common 文件夹,在工程的 Header Serach Paths中添加搜索路径 $(SRCROOT)/Common

common

获取头文件

使用 Google 搜索reason.h site:opensource.apple.com,百度不行。由于reason.hsys目录下,所以在Common目录中创建sys目录,并将reason.h放入sys目录中,重新编译。

以同样的方式解决下列问题:

  1. 'mach-o/dyld_priv.h' file not found
  2. 'os/lock_private.h' file not found
  3. 'os/base_private.h' file not found
  4. 'pthread/tsd_private.h' file not found
  5. 'System/machine/cpu_capabilities.h' file not found
  6. 'os/tsd.h' file not found
  7. 'pthread/spinlock_private.h' file not found
  8. 'System/pthread_machdep.h' file not found
  9. 'objc-shared-cache.h' file not found
  10. '_simple.h' file not found
  11. '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

other linker flags

SDK "macosx.internal" cannot be located.
unable to find utility "clang++", not a developer tool or in PATH

将Target objcBuild Phases->Run Script(markgc)里的内容macosx.internal改为macosx

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中的值

Text-Based

编译成功

处理完以上错误后,编译即可成功。可以在 objc-debugmain.m中添加代码,进行调试了。

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        NSObject *obj = [NSObject new];
        NSLog(@"obj:%@", obj);
    }
    return 0;
}

你可能感兴趣的:(objc4-756.2 编译)