ClangTrace
示例
要运行示例项目,请首先克隆仓库,然后从 Example 目录运行 pod install
。
构建设置:
在 App 的 Target
- Build Settings
中添加编译选项 Other C Flags
增加 -fsanitize-coverage=func,trace-pc-guard
OC - Swift 混编时,在
Other Swift Flags
增加-sanitize-coverage=func,-sanitize=undefined
Cocoapods 管理代码,如果使用静态库的方式,可以通过 hook 修改所有 pod 库的编译选项;将以下内容复制到你的 Podfile 文件下面,然后执行
pod install --no-repo-update
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
macho_type = config.build_settings['MACH_O_TYPE']
#if macho_type == 'staticlib'
# 将依赖的pod项目的Other C Flags加上’-fsanitize-coverage=func,trace-pc-guard‘选项
config.build_settings['OTHER_CFLAGS'] ||= ['$(inherited)', '-fsanitize-coverage=func,trace-pc-guard']
config.build_settings['OTHER_SWIFT_FLAGS'] ||= ['$(inherited)', '-fsanitize-coverage=func,trace-pc-guard']
#end
end
end
end
需求
iOS 9.0
安装
ClangTrace 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中
pod 'ClangTrace', :git => 'https://github.com/huipengo/ClangTrace.git', :configurations => ['Debug']
会在 App 的沙盒的 tmp 目录下生成 trace.order
文件
Xcode 的连接器 ld 默认忽略
order file
中不存在的方法
。如果设置Other Linker Flags:
-order_file_statistics
,会以warning
的形式把这些没找到的符号打印在日志里
作者
huipeng, [email protected]
许可
ClangTrace 在 MIT 许可下提供。更多信息请参阅 LICENSE 文件。