ClangTrace
Example
To run the example project, clone the repo, and run pod install from the Example directory first.
Build Settings:
在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
endRequirements
iOS 9.0
Installation
ClangTrace is available through CocoaPods. To install it, simply add the following line to your 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的形式把这些没找到的符号打印在日志里
Author
huipeng, [email protected]
License
ClangTrace is available under the MIT license. See the LICENSE file for more info.