ClangTrace 0.1.0

ClangTrace 0.1.0

Maintained by huipengo.



  • By
  • 彭辉

ClangTrace

CI Status Version License Platform

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
end

Requirements

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.

简书

iOS App启动优化 - 二进制重排