• Stars
    star
    1,530
  • Rank 30,597 (Top 0.7 %)
  • Language
    Objective-C
  • License
    BSD 3-Clause "New...
  • Created over 4 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Mach-O based ObjC & Swift useless classes, useless protocols, useless resources detection, packet size analysis, point-to-point crash resolution.基于Mach-O的ObjC & Swift无用类、无用协议、无用资源检测,包大小分析,点对点崩溃解析。

English | 简体中文

Introduction

WBBlades is a tool set based on Mach-O file parsing, including one-click detection for app (supports OC and Swift), package size analysis (supports a single static library/dynamic library), point-to-point crash analysis ( analyse system crash log, based on symbol file and without symbol files), Class automatic extraction and Hook capability based on Mach-O file. It mainly uses __Text assembly code analysis, architecture extraction, DYSM file stripping, symbol table stripping, crash file (ips) analysis technology.Support big method/small method parsing and iOS 15 above about dyld_chained_Fixups processing.

Tool Overview

Tool Name Function Overview Related Technologies
One-Click Detection for App Swift & OC useless class detection, useless resource detection, and package downsizing optimization suggestions. Disassembly, __Text instruction extraction, Mach-O parsing, symbol table and Swift class structure in Mach-O
Package Size Analysis Detecting the actual size occupied by static & dynamic libraries in .ipa file. Architecture stripping, static library structure analysis
Crash Analysis Using .app or dYSM file to parse the system crash log. DYSM file parsing, lightweight symbol table extraction, ips file parsing, with/without symbol table crash parsing
Mach-O Class Hook Automatically extract classes from any Mach-O file, and then hook them. dyld_ chained_ Fixups, binding, rebase, and big/small method parsing

The new version implements a comprehensive visual implementation of the toolset based on the original command-line-based operation of the above tools, and is designed for R&D efficiency improvement. In addition, in the analysis of difficult crashes, for some crashes that are not easy to reproduce and cannot be collected by general tools (the app process is directly killed by the operating system), a point-to-point crash analysis is provided.

Installation

$ git clone https://github.com/wuba/WBBlades.git
$ cd WBBlades
$ pod install

Usage of Visualization Tool

Target selects "WBBladesCrashApp".

The WBBlades visualization tool is shown below. Click the button on the left function area, select a tool such as Useless Classes Detection,Application Size Analysis,etc., and operate according to the prompts in the tool, and the result will be output to the text box;

mainpage

Detailed introduction to visualization tool: Detailed introduction to visualization tool

Usage for Mac Command Line

Target selects "WBBlades",Compile and build to generate command line tools Copy the generated product "blades" to /usr/local/bin,as follows: sudo cp ${Your_BUILD_DIR}/blades /usr/local/bin

  • One-click detection

    $ blades -diagnose xxx.app

    One-click detection of useless classes, useless resources, and duplicate resources, and so on.

  • Unused Code Detection ObjC & Swift

    $ blades -unused xxx.app -from xxx.a xxx.a ....

    -from indicating that only the unused code in the following static libraries is analyzed. Without this parameter, the default is all classes in the APP.

  • App Size Analysis (Directly measure the size of .a or .framework after linking)

    $ blades -size xxx.a xxx.framework ....

    Supporting input a folder path, all static libraries under the folder will be analyzed.

  • Log Recovery without dSYM File (In the case of missing dSYM file, try ObjC crash stack symbolization, Swift is not supported)

    $ blades -symbol xxx.app -logPath xxx.ips

Tool Features

Unused code (unused class) detection support range

Description Support Code Example
ObjC classes's static call [MyClass new]
ObjC classes's dynamic call NSClassFromString(@"MyClass")
ObjC dynamic call througn string concatenation NSClassFromString(@"My" + @"Class")
ObjC load method +load{...}
ObjC & Swift being inherited SomClass : MyClass
ObjC & Swift being properties @property (strong,atomic) MyClass *obj;
Swift class direct call MyClass.init()
Swift call using runtime objc_getClass("Demo.MyClass")
Swift generic parameters SomeClass<MyClass>.init()
Swfit class dynamic call in ObjC NSClassFromString("Demo.MyClass")
Swift type declaration in the container var array:[MyClass]
Swift multiple nesting class SomeClass {class MyClass {...} ...}

App Size Analysis Tool

Supports quick detection of the linked size of a static library. No need to compile and link. For example: If you want to know how much app size will increase when an SDK is imported or updated, you can use blades -size to estimate the size, without the need to connect the SDK to compile and link successfully to calculate.

Crash Log Symbolization Tool Without dSYM File

In the case of losing the dSYM file, try to restore the log via blades -symbol. **For example, in an app packaging, the dSYM file is cleared after a period of time, but the app file is retained. In this case, you can consider using blades for symbolization. **Before using the tool, pay attention to a few points:

  • If your app is a debug package or a package that does not strip the symbol table, you can use dsymutil app -o xx.dSYM to extract the symbol table. Then use the symbol table to symbolize the log.

  • This tool only supports ObjC, and its principle is to determine the function of the crash by analyzing the address of the ObjC method in Mach-O. Therefore, it is not suitable for Swfit, C, and C++. In addition, tools are not omnipotent, and are only used as emergency supplementary technical means. In daily situations, it is recommended to use symbol tables for log symbolization.

Contributing & Feedback

We sincerely hope that developers can provide valuable comments and suggestions, and developers can provide feedback on suggestions and problems by submitting PR or Issue.

If you are interested in WBBlades, you can join the WBBlades development group and discuss technical issues together. Please add the wechat account "zqlong320" or scan the QR code below as your friend and then we will invite you to join the group.

wechat_qrcode.png

Related Technical Articles

Thanks

GitHub: https://github.com/aquynh/capstone

GitHub: https://github.com/Sunnyyoung/SYFlatButton

GitHub: https://github.com/nygard/class-dump

GitHub: https://github.com/alexrozanski/PXListView

GitHub: https://github.com/steventroughtonsmith/cartool

DWARF: https://www.prevanders.net/dwarf.html#releases


简体中文 | English

简介

WBBlades是基于Mach-O文件解析的工具集,包括App一键体检(支持OCSwift的无用类检测)、包大小分析(支持单个静态库/动态库的包大小分析)、点对点崩溃解析(基于系统日志,支持有符号状态和无符号状态)、基于Mach-O的Class自动提取并Hook能力。主要利用了__Text汇编代码分析、架构提取、符号表剥离、dYSM文件提取、崩溃文件(ips)解析等技术手段实现,支持big method /small method 解析 以及 iOS 15以上关于 dyld_chained_fixups的处理。

工具概览

工具名称 功能概述 相关技术
App一键体检 Swift/OC无用类检测、无用资源检测、包瘦身优化建议 反汇编、__Text指令提取、Mach-O解析、符号表/Swift类在Mach-O中的结构
包大小分析 检测静态库/动态库在.ipa中占用的实际大小 架构剥离、静态库结构分析
崩溃解析 利用.app或者dYSM对系统崩溃日志解析 dYSM文件解析、轻量符号表提取、ips文件解析、有/无符号表崩溃解析
Mach-O类Hook 自动提取任意Mach-O中的Class并Hook dyld_chained_fixups 、binding、rebase、big/small method解析

新版本在原来基于命令行运行上述工具的基础上,对工具集进行了全面的可视化实现,开箱即用,专为研发提效而设计。另外,在疑难崩溃解析上,针对一些不易复现、且通用工具无法收集的崩溃(被操作系统直接杀死App进程场景),提供了基于系统日志的点对点崩溃解析功能。

安装

$ git clone https://github.com/wuba/WBBlades.git
$ cd WBBlades
$ pod install

使用

可视化工具用法

target选择:WBBladesCrashApp

WBBlades可视化工具如下图所示。点击左侧功能区按钮,点击进入无用类检测、包大小检测等工具,根据工具内的提示进行操作即可,具体的数据会输出到文本框中;

mainpage

可视化工具详细介绍: 可视化工具详细介绍

命令行工具blades用法

target选择:WBBlades,编译运行,生成命令行工具 将生成的产物blades 拷贝至 /usr/local/bin 下,具体操作如: sudo cp ${Your_BUILD_DIR}/blades /usr/local/bin

  • 一键诊断

    $ blades -diagnose xxx.app

    一键检测无用类、无用资源、重复资源等

  • 无用代码检测 OC & Swift

    $ blades -unused xxx.app -from xxx.a xxx.a ....

    -from 标识只分析以下静态库中的无用代码,不加此参数默认为APP中全部类

  • 包大小分析 (直接测算.a |.framework链接后的大小)

    $ blades -size xxx.a xxx.framework ....

    支持输入一个文件夹路径,输入后该文件下所有的静态库都会被分析

  • 无符号表日志符号化(在丢失符号表的情况下,尝试OC崩溃堆栈符号化,不支持Swift

    $ blades -symbol xxx.app -logPath xxx.ips

工具特性介绍

无用代码(无用类)检测支持范围

说明 是否支持 代码示例
OC 的类的静态调用 [MyClass new]
OC 的动态调用 NSClassFromString(@"MyClass")
OC 字符串拼接动态调用 NSClassFromString(@"My" + @"Class")
OC load方法使用 +load{...}
OC & Swift 被继承 SomClass : MyClass
OC & Swift 作为属性 @property (strong,atomic) MyClass *obj;
Swift 类直接调用 MyClass.init()
Swift 通过runtime调用 objc_getClass("Demo.MyClass")
Swift 泛型参数 SomeClass<MyClass>.init()
Swfit 类在OC中动态调用 NSClassFromString("Demo.MyClass")
Swift 容器中作为类型声明 var array:[MyClass]
Swift 多重嵌套 class SomeClass {class MyClass {...} ...}

包大小分析工具

支持快速检测一个静态库的链接后大小。无需编译链接。举例说明:如果你想知道一个接入或更新一个SDK对会增加多少包大小,可以用blades -size 来预估下大小,而无需将SDK接入编译链接成功后进行测算。

无符号表日志符号化工具

在丢失dSYM文件的情况下,尝试通过blades -symbol恢复日志。例如某次打包,在一段时间后符号表被清除,但是保留了app文件,这种情况下可以考虑使用WBBlades进行符号化。在工具使用前应先注意几点:

  • 如果你的app是debug包或者没有剥离符号表的包,那么可以通过dsymutil app -o xx.dSYM 来提取符号表。然后用符号表进行日志符号化。
  • 工具只适用于OC的场景,其原理为通过分析Mach-O中OC方法地址来确定崩溃的函数。因此不适用于Swfit、C、C++场景。另外,工具并非万能,仅作为应急补充技术手段,日常情况下还是推荐用符号表进行日志符号化。

如何贡献&反馈问题

我们诚挚地希望开发者提出宝贵的意见和建议,开发者可以通过提交PR或者Issue来反馈建议和问题。

对WBBlades感兴趣的小伙伴,可以加入WBBlades开发交流群,一起探讨技术问题,请先添加微信号"zqlong320"或者扫描下面的二维码为好友,备注WBBlades后,我们会邀请进群。

wechat_qrcode.png

相关技术文章

致谢

GitHub地址:https://github.com/aquynh/capstone

GitHub地址:https://github.com/Sunnyyoung/SYFlatButton

GitHub地址:https://github.com/nygard/class-dump

GitHub地址:https://github.com/alexrozanski/PXListView

GitHub地址:https://github.com/steventroughtonsmith/cartool

DWARF地址:https://www.prevanders.net/dwarf.html#releases

GitHub: https://github.com/nygard/class-dump

More Repositories

1

Fair

A Flutter package used to update widget tree dynamically. Fair提供一整套Flutter动态化解决方案
Dart
2,598
star
2

Picasso

一款UI自动生成代码插件,提供UI自动生成代码全流程解决方案。
TypeScript
1,126
star
3

react-native-echarts

📈 React Native ECharts Library: An awesome charting library for React Native, built upon Apache ECharts and leveraging react-native-svg and react-native-skia. Offers significantly better performance compared to WebView-based solutions.
TypeScript
729
star
4

Antenna

Antenna是58同城安全团队打造的一款辅助安全从业人员验证网络中多种漏洞是否存在以及可利用性的工具。其基于带外应用安全测试(OAST)通过任务的形式,将不同漏洞场景检测能力通过插件的形式进行集合,通过与目标进行out-bind的数据通信方式进行辅助检测。
JavaScript
719
star
5

Oceanus

58同城数据库中间件
Java
550
star
6

dl_inference

通用深度学习推理工具,可在生产环境中快速上线由TensorFlow、PyTorch、Caffe框架训练出的深度学习模型。
Java
405
star
7

Taro-Mortgage-Calculator

首个 Taro 3 多端统一实例 - 支持 React Native,Weapp,H5。
TypeScript
371
star
8

qa_match

A simple effective ToolKit for short text matching
Python
328
star
9

FairPushy

FairPushy 基于Dart三端一体化动态更新平台,为Flutter Fair设计的动态化框架提供动态分发能力
Dart
268
star
10

taro-playground

The Taro Playground App is a cross-platform application developed using Taro, to help developers develop and debug Taro applications.
TypeScript
253
star
11

metro-code-split

Further split the React Native code based on Metro build to improve performance, providing `Dll` and `Dynamic Imports` features
JavaScript
203
star
12

WPaxos

A production-grade java implementation of paxos consensus algorithm
Java
195
star
13

WLock

A high-reliable, high-throughput distributed lock service based on the consensus algorithm component WPaxos.
Java
184
star
14

magpie

Magpie is a visualized platform which designed to create, develop and compile your standalone flutter module.
Dart
123
star
15

wwto

WWTO,小程序跨端迁移解决方案,低成本将微信小程序转为其他平台(百度、支付宝、头条)小程序。
JavaScript
106
star
16

Zucker

An easier way to automatically calculate the size of AAR in apk based on APP module
Python
88
star
17

LPA-Detector

Optimize and improve the Label propagation algorithm
Java
88
star
18

mp-monitor

mp-monitor脱胎于58内部前端质量监控系统“北斗”。致力于为小程序异常采集和性能统计分析提供采集方案和统一的数据指标,适配多端小程序(微信,头条,支付宝,百度,QQ,360,JD)。 如果开发者想要在自己的项目中快速搭建小程序的异常采集和性能监控数据分析。mp-monitor将能帮助用户快速采集到相关的数据用于分析和监控。
TypeScript
68
star
19

magpie_sdk

A Native-Futter hybrid development solution. Native developers do not need to install FlutterSDK. This Flutter plugin provides general capabilities such as routing management and dynamic protocol registration.
Objective-C
50
star
20

magpie_log

A visualized dynamic programming for log collection based on flutter.
Dart
48
star
21

magpie_fly

Magpie-fly is a component library produced by 58 Group, which encapsulates a variety of common components to meet the needs of developers
Dart
38
star
22

taro-visualization

TypeScript
33
star
23

json-model-validator

A flexible, lightweight JSON Data validator and formatter
TypeScript
30
star
24

wsilk

wsilk是一个辅助开发人员的代码生成框架(wsilk is a framework that assists developers to generate code)
Java
26
star
25

Taro-Code-In-React-Native

Taro React Native 参考样例。支持在 React Native 初始化的项目中引入 Taro 3 代码。
JavaScript
22
star
26

EasyAOP

EasyAOP是基于ASM实现切面通用能力的工具。EasyAOP提供的通用切面能力,可以使用配置文件方式来配置使用。(EasyAOP is a tool based on ASM to realize the general capability of AOP. General faceting capabilities provided by EasyAOP,You can use the yaml file format to configure the use of EasyAOP.)
Kotlin
22
star
27

first-meaning-paint

首次有效绘制表示当前页面最想展示给用户的元素渲染的时间点,即主元素渲染点。
JavaScript
11
star
28

FairTemplate

FairTemplate 是为Fair 开发者设计的常用基础组件库及代码模板,结合Fair 团队自研的IDE 插件,快速地搭建Fair 动态化页面,提升Fair 的开发效率。
Dart
5
star
29

ideaPlugin-MavenManager

Manage dependencies of maven project to resolve jar conflicts
Java
3
star