介绍
- 摇一摇手机隐藏/显示黑色小球 (支持真机/模拟器)
-
长按黑色小球显示
UIDebuggingInformationOverlay
(苹果私有方法,支持iOS10/11/12) - 内存占用情况,以及 FPS
- 列出崩溃信息 (可选)
-
列出 Xcode 里面所有的
print()
和NSLog()
日志信息 (可选) - 列出所有网络请求 (可选)
- 在 Network Details 页面,可以分享网络日志信息 (通过邮箱/拷贝)
- 复制日志 (长按文字,选择全选/拷贝)
- 通过关键字搜索日志
- 列出 APP 信息和设备信息,包括:version, build, bundle name, bundle id, screen resolution, device, iOS version
- 列出沙盒所有文件夹和文件,支持预览和编辑
-
列出 HTML 日志, 包含
console.log()
,console.debug()
,console.warn()
,console.error()
,console.info()
(支持WKWebView
和UIWebView
) (可选) -
支持
JSON
和 Google的Protocol buffers
安装
CocoaPods
platform :ios, '8.0' use_frameworks! target 'YourTargetName' do pod 'CocoaDebug', :configurations => ['Debug'] end
Carthage
github "CocoaDebug/CocoaDebug"
警告:不要在将要发布到AppStore的
.ipa
中导入CocoaDebug.framework
。阅读这篇集成指南,了解如何仅在Debug
环境下导入CocoaDebug.framework
。
使用
Swift
//Step 1. (AppDelegate.swift) #if DEBUG import CocoaDebug #endif //Step 2. (AppDelegate.swift) #if DEBUG CocoaDebug.enable() #endif //Step 3. (AppDelegate.swift) public func print<T>(file: String = #file, function: String = #function, line: Int = #line, _ message: T, color: UIColor = .white) { #if DEBUG swiftLog(file, function, line, message, color, false) #endif }
Objective-C
//Step 1. (AppDelegate.m) #ifdef DEBUG @import CocoaDebug; #endif //Step 2. (AppDelegate.m) #ifdef DEBUG [CocoaDebug enable]; #endif
更多高级用法,请查看示例代码。
注意:如果项目使用了Swift和Objective-C混编,请小心使用
Other Swift Flags
和Preprocessor Macros
,可以参考这里。
参数
初始化CocoaDebug时,可以在CocoaDebug.enable()
之前自定义以下这些参数值:
-
serverURL
- 如果被抓取的网址包含serverURL,这些网址会被加粗标记。当该参数为nil时,所有网址都不会被加粗标记。默认值为nil -
ignoredURLs
- 设置不被抓取的网址,忽略大小写。当该参数为nil时,抓取所有网址。默认值为nil -
onlyURLs
- 设置被抓取的网址,忽略大小写。当该参数为nil时,抓取所有网址。默认值为nil -
tabBarControllers
- 设置controllers作为UITabBarController的子控制器,默认值为nil -
logMaxCount
- 设置日志显示的最大数值,默认值为1000 -
emailToRecipients
- 通过邮件分享日志时,设置收件地址,默认值为nil -
emailCcRecipients
- 通过邮件分享日志时,设置抄送地址,默认值为nil -
mainColor
- 设置CocoaDebug主色调,颜色格式为十六进制。默认值为 #42d459