# CocoaDebug | iOS Debugging Tool

**URL:** <https://onehack.st/t/cocoadebug-ios-debugging-tool/86886>\
**Category:** Tools & Scripts\
**Tags:** tools, operating-system\
**Created:** [May 16, 2020, 1:57pm UTC](https://onehack.st/t/cocoadebug-ios-debugging-tool/86886 "2020-05-16T13:57:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheStrength](https://onehack.st/user_avatar/onehack.st/thestrength/32/46753_2.png) [@TheStrength](https://onehack.st/u/TheStrength)\
**Post date:** [May 16, 2020, 1:57pm UTC](https://onehack.st/t/cocoadebug-ios-debugging-tool/86886/1 "2020-05-16T13:57:09Z")

</div>

![image](https://onehack.st/uploads/default/original/3X/d/6/d65d40a272c0d9c0fe8354967c7273c01c07185b.png)

**Debugging** is the process of finding and resolving defects or problems within a computer program that prevent correct operation of computer software or a system. Tool that can help you to perform debugging on iOS system is **CocoaDebug**. This tool is very helpful to perform debugging and find a bugs on system to fix it.

## Introduction

![](https://i.imgur.com/Y5q20uG.gif)

- Shake to hide or show the black bubble. (support both device and simulator)
- Long press the black bubble to show `UIDebuggingInformationOverlay` . (Apple’s Private API, support iOS 10/11/12)
- Application memory usage and _FPS_ .
- List all `print()` and `NSLog()` messages which have been written by developer in Xcode.
- List of all the network requests sent by the application.
- List crash errors.
- Share network details via email or copy to clipboard when you are in the _Network Details_ page.
- Copy logs. (long press the text, then select all or select copy)
- Search logs by keyword.
- List application and device informations, including: _version_ , _build_ , _bundle name_ , _bundle id_ , _screen resolution_ , _device_ , _iOS version_
- List all sandbox folders and files, supporting to preview and edit.
- List HTML logs, including `console.log()` , `console.debug()` , `console.warn()` , `console.error()` , `console. info()` . (support both `WKWebView` and `UIWebView` ).
- Support `JSON` and Google’s `Protocol buffers`

## Installation

### CocoaPods

target ‘YourTargetName’ do pod ‘CocoaDebug’, :configurations =\> [‘Debug’] end

### Carthage

github “CocoaDebug/CocoaDebug”

### Framework

[Download](https://github.com/CocoaDebug/CocoaDebug/raw/master/CocoaDebug.framework.zip)

> WARNING: Don’t submit `.ipa` to AppStore which has been linked with the `CocoaDebug.framework` . This [Integration Guide](https://github.com/CocoaDebug/CocoaDebug/wiki/Integration-Guide) outline a way to use build configurations to isolate linking the framework to `Debug` builds only.

## Usage

### Swift

```auto
//AppDelegate.swift

```

```auto
 

```

```auto
#if DEBUG

```

```auto
    import CocoaDebug

```

```auto
#endif

```

```auto
 

```

```auto
#if DEBUG

```

```auto
    CocoaDebug.enable()

```

```auto
#endif

```

```auto
 

```

```auto
public func print<T>(file: String = #file, function: String = #function, line: Int = #line, _ message: T, color: UIColor = .white) {

```

```auto
    #if DEBUG

```

```auto
        swiftLog(file, function, line, message, color, false)

```

```auto
    #endif

```

```auto
}

```

### Objective-C

```auto
//AppDelegate.m

```

```auto
 

```

```auto
#ifdef DEBUG

```

```auto
    @import CocoaDebug;

```

```auto
#endif

```

```auto
 

```

```auto
#ifdef DEBUG

```

```auto
    [CocoaDebug enable];

```

```auto
#endif

```

Please check `Example_Swift.xcodeproj` and `Example_Objc.xcodeproj` for more advanced usage.

> NOTE: Be careful with `Other Swift Flags` & `Preprocessor Macros` when using Swift & Objective-C in one project. You can refer to [here](https://stackoverflow.com/questions/24111854/in-absence-of-preprocessor-macros-is-there-a-way-to-define-practical-scheme-spe).

## Parameters

When you initialize CocoaDebug, you can customize the following parameter values before `CocoaDebug.enable()` .

- `serverURL` – If the crawled URLs contain server URL ,set these URLs bold font to be marked. not mark when this value is nil. default value is **nil**.
- `ignoredURLs` – Set the URLs which should not crawled, ignoring case, crawl all URLs when the value is nil. default value is **nil**.
- `onlyURLs` – Set the URLs which are only crawled, ignoring case, crawl all URLs when the value is nil. default value is **nil**.
- `tabBarControllers` – Set controllers to be added as child controllers of UITabBarController. default value is **nil**.
- `logMaxCount` – The maximum count of logs which CocoaDebug display. default value is **1000**.
- `emailToRecipients` – Set the initial recipients to include in the email’s “To” field when share via email. default value is **nil**.
- `emailCcRecipients` – Set the initial recipients to include in the email’s “Cc” field when share via email. default value is **nil**.
- `mainColor` – Set the main color with hexadecimal format. default value is **#42d459**.

## TODO

- [Unit Testing](https://codecov.io/gh/CocoaDebug/CocoaDebug)

## Thanks

Special thanks to **[remirobert](https://github.com/remirobert)**.

## GitHub:

> **[GitHub - CocoaDebug/CocoaDebug: iOS Debugging Tool 🚀](https://github.com/CocoaDebug/CocoaDebug)**
>
> iOS Debugging Tool 🚀
