文章目录

  • 编译单个 Target 过程 (以 AFNetworking 为例子)
  • 一、准备工作
  • 1、CreateBuildDirectory (产品 `Products` 最终路径: Build/Products)
  • 2、CreateBuildDirectory (产品 `Products` 中间文件路径: Build/Intermediates.noindexs)
  • 二、 WriteAuxiliaryFile (写入辅助文件)
  • 1、all-product-headers.yaml
  • 2、.hmap 相关
  • 3、.LinkFileList (链接的对象文件`.o`列表)
  • 三、CompileC (编译源文件)
  • 四、Libtool (链接 .o 文件 生成 `.a` 静态库)


编译单个 Target 过程 (以 AFNetworking 为例子)

转载请注明出处!!!

一、准备工作

Build target AFNetworking of project Pods with configuration Debug

1、CreateBuildDirectory (产品 Products 最终路径: Build/Products)

命令是 builtin-create-build-directory

// 创建 build products 文件夹
CreateBuildDirectory /Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Products (in target: AFNetworking)
    cd /Users/ocean/Desktop/code/iOS/Company/Myway/MyAppName/MyAppName/Pods
    builtin-create-build-directory /Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Products

AFNetworking 文件夹内容如下:

$ cd /Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Products/Debug-iphonesimulator/AFNetworking 
$ tree
.
└── libAFNetworking.a

libAFNetworking.a就是最终生成的静态库

2、CreateBuildDirectory (产品 Products 中间文件路径: Build/Intermediates.noindexs)

命令是 builtin-create-build-directory

// 创建 build products 临时的文件夹
CreateBuildDirectory /Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex (in target: AFNetworking)
    cd /Users/ocean/Desktop/code/iOS/Company/Myway/MyAppName/MyAppName/Pods
    builtin-create-build-directory /Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex

AFNetworking.build 内容如下:

$ cd /Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build 
$ tree
.
├── AFNetworking-all-non-framework-target-headers.hmap
├── AFNetworking-all-target-headers.hmap
├── AFNetworking-generated-files.hmap
├── AFNetworking-own-target-headers.hmap
├── AFNetworking-project-headers.hmap
├── AFNetworking.hmap
├── Objects-normal (这个是编程生成的对象文件.o存放的位置)
│   └── x86_64 (架构)
│       ├── AFAutoPurgingImageCache.d
│       ├── AFAutoPurgingImageCache.dia
│       ├── AFAutoPurgingImageCache.o
│       ├── AFHTTPSessionManager.d
│       ├── AFHTTPSessionManager.dia
│       ├── AFHTTPSessionManager.o
│       ├── AFImageDownloader.d
│       ├── AFImageDownloader.dia
│       ├── AFImageDownloader.o
│       ├── AFNetworkActivityIndicatorManager.d
│       ├── AFNetworkActivityIndicatorManager.dia
│       ├── AFNetworkActivityIndicatorManager.o
│       ├── AFNetworkReachabilityManager.d
│       ├── AFNetworkReachabilityManager.dia
│       ├── AFNetworkReachabilityManager.o
│       ├── AFNetworking-dummy.d
│       ├── AFNetworking-dummy.dia
│       ├── AFNetworking-dummy.o
│       ├── AFNetworking.LinkFileList
│       ├── AFSecurityPolicy.d
│       ├── AFSecurityPolicy.dia
│       ├── AFSecurityPolicy.o
│       ├── AFURLRequestSerialization.d
│       ├── AFURLRequestSerialization.dia
│       ├── AFURLRequestSerialization.o
│       ├── AFURLResponseSerialization.d
│       ├── AFURLResponseSerialization.dia
│       ├── AFURLResponseSerialization.o
│       ├── AFURLSessionManager.d
│       ├── AFURLSessionManager.dia
│       ├── AFURLSessionManager.o
│       ├── UIActivityIndicatorView+AFNetworking.d
│       ├── UIActivityIndicatorView+AFNetworking.dia
│       ├── UIActivityIndicatorView+AFNetworking.o
│       ├── UIButton+AFNetworking.d
│       ├── UIButton+AFNetworking.dia
│       ├── UIButton+AFNetworking.o
│       ├── UIImageView+AFNetworking.d
│       ├── UIImageView+AFNetworking.dia
│       ├── UIImageView+AFNetworking.o
│       ├── UIProgressView+AFNetworking.d
│       ├── UIProgressView+AFNetworking.dia
│       ├── UIProgressView+AFNetworking.o
│       ├── UIRefreshControl+AFNetworking.d
│       ├── UIRefreshControl+AFNetworking.dia
│       ├── UIRefreshControl+AFNetworking.o
│       ├── UIWebView+AFNetworking.d
│       ├── UIWebView+AFNetworking.dia
│       └── UIWebView+AFNetworking.o
└── all-product-headers.yaml
  • AFNetworking.LinkFileList: 存储的生成.a静态库所需要链接的对象文件.o
  • 每一个类都三个文件 .d.dia.o

补充介绍:每一个类都会生成 .d .dia .o 这三个文件

  • .d: 表示这个类所依赖的其他类,即使用import导入的头文件,会自动寻找所有的依赖头文件,包含多级依赖 (a依赖bb又依赖c,那么最终a也会依赖c)
  • .dia: 是diagnose的简写,就是诊断的意思,我们在Xcode写的源代码,经过编译的时候有时候会生成一些警告信息,都是放到这里面的
  • .o: 对象文件,.m经过编译生成.o文件,用来链接到静态库/可执行文件中

UIWebView+AFNetworking.d: 打开内容如下:

dependencies: \
  /Users/ocean/Desktop/code/iOS/Company/Myway/MyAppName/MyAppName/Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.m \
  /Users/ocean/Desktop/code/iOS/Company/Myway/MyAppName/MyAppName/Pods/Target\ Support\ Files/AFNetworking/AFNetworking-prefix.pch \
  /Users/ocean/Desktop/code/iOS/Company/Myway/MyAppName/MyAppName/Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h \
  /Users/ocean/Desktop/code/iOS/Company/Myway/MyAppName/MyAppName/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.h \
  /Users/ocean/Desktop/code/iOS/Company/Myway/MyAppName/MyAppName/Pods/AFNetworking/AFNetworking/AFURLSessionManager.h \
  /Users/ocean/Desktop/code/iOS/Company/Myway/MyAppName/MyAppName/Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.h \
  /Users/ocean/Desktop/code/iOS/Company/Myway/MyAppName/MyAppName/Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.h \
  /Users/ocean/Desktop/code/iOS/Company/Myway/MyAppName/MyAppName/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.h \
  /Users/ocean/Desktop/code/iOS/Company/Myway/MyAppName/MyAppName/Pods/AFNetworking/AFNetworking/AFCompatibilityMacros.h \
  /Users/ocean/Desktop/code/iOS/Company/Myway/MyAppName/MyAppName/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.h

补充 ,使用 clang 来编译文件的一些命令如下

-MMD -MT dependencies -MF /Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/Objects-normal/x86_64/UIWebView+AFNetworking.d 
    --serialize-diagnostics /Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/Objects-normal/x86_64/UIWebView+AFNetworking.dia

二、 WriteAuxiliaryFile (写入辅助文件)

命令都是 write-file

1、all-product-headers.yaml

命令是 write-file

// 写入辅助文件 all-product-headers.yaml
WriteAuxiliaryFile /Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/all-product-headers.yaml (in target: AFNetworking)
    cd /Users/ocean/Desktop/code/iOS/Company/Myway/MyAppName/MyAppName/Pods
    write-file /Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/all-product-headers.yaml

打开内容如下:

{
  'version': 0,
  'case-sensitive': 'false',
  'roots': [

  ]
}

2、.hmap 相关

命令是 write-file

用作头文件搜索相关

// 写入辅助文件 AFNetworking.hmap
WriteAuxiliaryFile /Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/AFNetworking.hmap (in target: AFNetworking)
    cd /Users/ocean/Desktop/code/iOS/Company/Myway/MyAppName/MyAppName/Pods
    write-file /Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/AFNetworking.hmap

// 写入辅助文件 AFNetworking-project-headers.hmap
WriteAuxiliaryFile /Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/AFNetworking-project-headers.hmap (in target: AFNetworking)
    cd /Users/ocean/Desktop/code/iOS/Company/Myway/MyAppName/MyAppName/Pods
    write-file /Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/AFNetworking-project-headers.hmap

// 写入辅助文件 AFNetworking-own-target-headers.hmap
WriteAuxiliaryFile /Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/AFNetworking-own-target-headers.hmap (in target: AFNetworking)
    cd /Users/ocean/Desktop/code/iOS/Company/Myway/MyAppName/MyAppName/Pods
    write-file /Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/AFNetworking-own-target-headers.hmap

// 写入辅助文件 AFNetworking-generated-files.hmap
WriteAuxiliaryFile /Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/AFNetworking-generated-files.hmap (in target: AFNetworking)
    cd /Users/ocean/Desktop/code/iOS/Company/Myway/MyAppName/MyAppName/Pods
    write-file /Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/AFNetworking-generated-files.hmap

// 写入辅助文件 AFNetworking-all-target-headers.hmap
WriteAuxiliaryFile /Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/AFNetworking-all-target-headers.hmap (in target: AFNetworking)
    cd /Users/ocean/Desktop/code/iOS/Company/Myway/MyAppName/MyAppName/Pods
    write-file /Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/AFNetworking-all-target-headers.hmap

// 写入辅助文件 AFNetworking-all-non-framework-target-headers.hmap
WriteAuxiliaryFile /Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/AFNetworking-all-non-framework-target-headers.hmap (in target: AFNetworking)
    cd /Users/ocean/Desktop/code/iOS/Company/Myway/MyAppName/MyAppName/Pods
    write-file /Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/AFNetworking-all-non-framework-target-headers.hmap

3、.LinkFileList (链接的对象文件.o列表)

命令是 write-file

// 写入辅助文件 AFNetworking.LinkFileList (存储的.o文件)
WriteAuxiliaryFile /Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/Objects-normal/x86_64/AFNetworking.LinkFileList (in target: AFNetworking)
    cd /Users/ocean/Desktop/code/iOS/Company/Myway/MyAppName/MyAppName/Pods
    write-file /Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/Objects-normal/x86_64/AFNetworking.LinkFileList

打开AFNetworking.LinkFileList文件如下: 存储的是对象文件.o,最终是通过这些对象文件 .o 生成静态库 .a

/Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/Objects-normal/x86_64/AFAutoPurgingImageCache.o
/Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/Objects-normal/x86_64/AFHTTPSessionManager.o
/Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/Objects-normal/x86_64/AFImageDownloader.o
/Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/Objects-normal/x86_64/AFNetworkActivityIndicatorManager.o
/Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/Objects-normal/x86_64/AFNetworking-dummy.o
/Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/Objects-normal/x86_64/AFNetworkReachabilityManager.o
/Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/Objects-normal/x86_64/AFSecurityPolicy.o
/Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/Objects-normal/x86_64/AFURLRequestSerialization.o
/Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/Objects-normal/x86_64/AFURLResponseSerialization.o
/Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/Objects-normal/x86_64/AFURLSessionManager.o
/Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/Objects-normal/x86_64/UIActivityIndicatorView+AFNetworking.o
/Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/Objects-normal/x86_64/UIButton+AFNetworking.o
/Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/Objects-normal/x86_64/UIImageView+AFNetworking.o
/Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/Objects-normal/x86_64/UIProgressView+AFNetworking.o
/Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/Objects-normal/x86_64/UIRefreshControl+AFNetworking.o
/Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/Objects-normal/x86_64/UIWebView+AFNetworking.o

三、CompileC (编译源文件)

会对所有的源文件进行编译;

.m 文件 经过编译器 com.apple.compilers.llvm.clang.1_0.compiler 编译成 .o文件 (UIWebView+AFNetworking.m -> UIWebView+AFNetworking.o)

  • x86_64: 架构
  • objective-c: 语言
  • com.apple.compilers.llvm.clang.1_0.compiler: 使用的编译器

补充:

  • 编译工具clang路径是 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
CompileC /Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/Objects-normal/x86_64/UIWebView+AFNetworking.o /Users/ocean/Desktop/code/iOS/Company/Myway/MyAppName/MyAppName/Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (in target: AFNetworking)
    cd /Users/ocean/Desktop/code/iOS/Company/Myway/MyAppName/MyAppName/Pods
    export LANG=en_US.US-ASCII
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang 
    -x objective-c 
    -arch x86_64 
    -fmessage-length=0 
    -fdiagnostics-show-note-include-stack 
    -fmacro-backtrace-limit=0 
    -std=gnu11 
    -fobjc-arc 
    -fobjc-weak 
    -fmodules 
    -fmodules-cache-path=/Users/ocean/Library/Developer/Xcode/DerivedData/ModuleCache.noindex 
    -fmodules-prune-interval=86400 
    -fmodules-prune-after=345600 
    -fbuild-session-file=/Users/ocean/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation 
    -fmodules-validate-once-per-build-session 
    -Wnon-modular-include-in-framework-module 
    -Werror=non-modular-include-in-framework-module 
    -Wno-trigraphs 
    -fpascal-strings 
    -O0 
    -fno-common 
    -Wno-missing-field-initializers 
    -Wno-missing-prototypes 
    -Werror=return-type 
    -Wdocumentation 
    -Wunreachable-code 
    -Wno-implicit-atomic-properties 
    -Werror=deprecated-objc-isa-usage 
    -Wno-objc-interface-ivars 
    -Werror=objc-root-class 
    -Wno-arc-repeated-use-of-weak 
    -Wimplicit-retain-self 
    -Wduplicate-method-match 
    -Wno-missing-braces 
    -Wparentheses 
    -Wswitch 
    -Wunused-function 
    -Wno-unused-label 
    -Wno-unused-parameter 
    -Wunused-variable 
    -Wunused-value 
    -Wempty-body 
    -Wuninitialized 
    -Wconditional-uninitialized 
    -Wno-unknown-pragmas 
    -Wno-shadow 
    -Wno-four-char-constants 
    -Wno-conversion 
    -Wconstant-conversion 
    -Wint-conversion 
    -Wbool-conversion 
    -Wenum-conversion 
    -Wno-float-conversion 
    -Wnon-literal-null-conversion 
    -Wobjc-literal-conversion 
    -Wshorten-64-to-32 
    -Wpointer-sign 
    -Wno-newline-eof 
    -Wno-selector 
    -Wno-strict-selector-match 
    -Wundeclared-selector 
    -Wdeprecated-implementations 
    -DPOD_CONFIGURATION_DEBUG=1 
    -DDEBUG=1 
    -DCOCOAPODS=1 
    -DOBJC_OLD_DISPATCH_PROTOTYPES=0 
    -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk 
    -fasm-blocks 
    -fstrict-aliasing 
    -Wprotocol 
    -Wdeprecated-declarations 
    -mios-simulator-version-min=7.0 
    -g 
    -Wno-sign-conversion 
    -Winfinite-recursion 
    -Wcomma 
    -Wblock-capture-autoreleasing 
    -Wstrict-prototypes 
    -Wno-semicolon-before-method-body 
    -Wunguarded-availability 
    -fobjc-abi-version=2 
    -fobjc-legacy-dispatch 
    -index-store-path /Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Index/DataStore 
    -iquote /Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/AFNetworking-generated-files.hmap 
    -I/Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/AFNetworking-own-target-headers.hmap 
    -I/Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/AFNetworking-all-target-headers.hmap 
    -iquote /Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/AFNetworking-project-headers.hmap 
    -I/Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Products/Debug-iphonesimulator/AFNetworking/include 
    -I/Users/ocean/Desktop/code/iOS/Company/Myway/MyAppName/MyAppName/Pods/Headers/Private 
    -I/Users/ocean/Desktop/code/iOS/Company/Myway/MyAppName/MyAppName/Pods/Headers/Private/AFNetworking 
    -I/Users/ocean/Desktop/code/iOS/Company/Myway/MyAppName/MyAppName/Pods/Headers/Public 
    -I/Users/ocean/Desktop/code/iOS/Company/Myway/MyAppName/MyAppName/Pods/Headers/Public/AFNetworking 
    -I/Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/DerivedSources/x86_64 
    -I/Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/DerivedSources 
    -F/Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Products/Debug-iphonesimulator/AFNetworking 
    -include /Users/ocean/Desktop/code/iOS/Company/Myway/MyAppName/MyAppName/Pods/Target\ Support\ Files/AFNetworking/AFNetworking-prefix.pch 
    -MMD 
    -MT dependencies 
    -MF /Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/Objects-normal/x86_64/UIWebView+AFNetworking.d 
    --serialize-diagnostics /Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/Objects-normal/x86_64/UIWebView+AFNetworking.dia 
    -c /Users/ocean/Desktop/code/iOS/Company/Myway/MyAppName/MyAppName/Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.m 
    -o /Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/Objects-normal/x86_64/UIWebView+AFNetworking.o

补充:一些常用的标识的含义


  • -x <language>: 输入文件是用什么编程语言写的
-x objective-c

  • -arch <architecture>: 编译的架构
-arch x86_64

  • -std=<standard>: 编程语言的标准集
-std=gnu11

  • -O0: 代码生成的时候的一些优化
-O0

  • -D<macroname>=<value>: 宏定义 #define
-DPOD_CONFIGURATION_DEBUG=1 
-DDEBUG=1 
-DCOCOAPODS=1 
-DOBJC_OLD_DISPATCH_PROTOTYPES=0

  • -iquote <directory>: inclue 的搜索路径
  • -I<directory>: 头文件搜索文件夹
  • -F<directory>: framework搜索文件
-iquote /Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/AFNetworking-generated-files.hmap 
    -I/Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/AFNetworking-own-target-headers.hmap 
    -I/Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/AFNetworking-all-target-headers.hmap 
    -iquote /Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/AFNetworking-project-headers.hmap 
    -I/Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Products/Debug-iphonesimulator/AFNetworking/include 
    -I/Users/ocean/Desktop/code/iOS/Company/Myway/MyAppName/MyAppName/Pods/Headers/Private 
    -I/Users/ocean/Desktop/code/iOS/Company/Myway/MyAppName/MyAppName/Pods/Headers/Private/AFNetworking 
    -I/Users/ocean/Desktop/code/iOS/Company/Myway/MyAppName/MyAppName/Pods/Headers/Public 
    -I/Users/ocean/Desktop/code/iOS/Company/Myway/MyAppName/MyAppName/Pods/Headers/Public/AFNetworking 
    -I/Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/DerivedSources/x86_64 
    -I/Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/DerivedSources
    -F/Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Products/Debug-iphonesimulator/AFNetworking

表示的是依赖的文件 .d

  • -MMD
  • -MT dependencies
  • -MF
-MMD 
    -MT dependencies 
    -MF /Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/Objects-normal/x86_64/UIWebView+AFNetworking.d

  • --serialize-diagnostics: 代码诊断结果 .dia
--serialize-diagnostics /Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/Objects-normal/x86_64/UIWebView+AFNetworking.dia

  • -W: 编译警告
  • -Werror: 警告转错误

  • -c : 表示编译步骤: preprocess compile assemble ,没有链接步骤
-c /Users/ocean/Desktop/code/iOS/Company/Myway/MyAppName/MyAppName/Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.m

  • -o <file>: 把输出写入到文件中
-o /Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/Objects-normal/x86_64/UIWebView+AFNetworking.o

-fmessage-length=0 
    -fdiagnostics-show-note-include-stack 
    -fmacro-backtrace-limit=0 
    
    -fno-common
    
    -fobjc-arc 
    -fobjc-weak 
    
    -fpascal-strings
    -fasm-blocks 
    -fstrict-aliasing 
    
    // 模块相关
    -fmodules 
    -fmodules-cache-path=/Users/ocean/Library/Developer/Xcode/DerivedData/ModuleCache.noindex 
    -fmodules-prune-interval=86400 
    -fmodules-prune-after=345600 
    -fbuild-session-file=/Users/ocean/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation 
    -fmodules-validate-once-per-build-session 
    
    
    -Wnon-modular-include-in-framework-module 
    -Wno-trigraphs 
    -Werror=non-modular-include-in-framework-module 
    -Wno-missing-field-initializers 
    -Wno-missing-prototypes 
    -Werror=return-type 
    -Wdocumentation 
    -Wunreachable-code 
    -Wno-implicit-atomic-properties 
    -Werror=deprecated-objc-isa-usage 
    -Wno-objc-interface-ivars 
    -Werror=objc-root-class 
    -Wno-arc-repeated-use-of-weak 
    -Wimplicit-retain-self 
    -Wduplicate-method-match 
    -Wno-missing-braces 
    -Wparentheses 
    -Wswitch 
    -Wunused-function 
    -Wno-unused-label 
    -Wno-unused-parameter 
    -Wunused-variable 
    -Wunused-value 
    -Wempty-body 
    -Wuninitialized 
    -Wconditional-uninitialized 
    -Wno-unknown-pragmas 
    -Wno-shadow 
    -Wno-four-char-constants 
    -Wno-conversion 
    -Wconstant-conversion 
    -Wint-conversion 
    -Wbool-conversion 
    -Wenum-conversion 
    -Wno-float-conversion 
    -Wnon-literal-null-conversion 
    -Wobjc-literal-conversion 
    -Wshorten-64-to-32 
    -Wpointer-sign 
    -Wno-newline-eof 
    -Wno-selector 
    -Wno-strict-selector-match 
    -Wundeclared-selector 
    -Wdeprecated-implementations 
    -Wprotocol 
    -Wdeprecated-declarations
    -Wno-sign-conversion 
    -Winfinite-recursion 
    -Wcomma 
    -Wblock-capture-autoreleasing 
    -Wstrict-prototypes 
    -Wno-semicolon-before-method-body 
    -Wunguarded-availability 
    
    -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk 
    
     
    -mios-simulator-version-min=7.0 
    -g 
    
    -fobjc-abi-version=2 
    -fobjc-legacy-dispatch 
    -index-store-path /Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Index/DataStore 
    
    
    -include /Users/ocean/Desktop/code/iOS/Company/Myway/MyAppName/MyAppName/Pods/Target\ Support\ Files/AFNetworking/AFNetworking-prefix.pch

四、Libtool (链接 .o 文件 生成 .a 静态库)

  • libtool路径是 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool
// 生成静态库,把 所有的.o 文件生成 .a静态库
Libtool /Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Products/Debug-iphonesimulator/AFNetworking/libAFNetworking.a normal x86_64 (in target: AFNetworking)
    cd /Users/ocean/Desktop/code/iOS/Company/Myway/MyAppName/MyAppName/Pods
    export IPHONEOS_DEPLOYMENT_TARGET=7.0
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool 
    -static 
    -arch_only x86_64 
    -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk 
    -L/Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Products/Debug-iphonesimulator/AFNetworking 
    -filelist /Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AFNetworking.build/Objects-normal/x86_64/AFNetworking.LinkFileList 
    -o /Users/ocean/Library/Developer/Xcode/DerivedData/MyAppName-eexzhxxmdkygpcfkoprwzzghvpkj/Build/Products/Debug-iphonesimulator/AFNetworking/libAFNetworking.a

补充 libtool 的命令参数

用法一、静态库

Usage: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool 
-static [-] 
file [...] [-filelist listfile[,dirname]] 
[-arch_only arch] 
[-sacLT] 
[-no_warning_for_no_symbols]

用法二、动态库

Usage: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool 
-dynamic [-] 
file [...] [-filelist listfile[,dirname]] 
[-arch_only arch] 
[-o output] 
[-install_name name] 
[-compatibility_version #] 
[-current_version #] 
[-seg1addr 0x#] 
[-segs_read_only_addr 0x#] [-segs_read_write_addr 0x#] 
[-seg_addr_table <filename>] [-seg_addr_table_filename <file_system_path>] 
[-all_load] [-noall_load]