CocoaDebug - iOS Debugging Tool

CocoaDebug

iOS Debugging Tool.

  • [x] Shake to hide or show the black bubble. (support both device and simulator)

  • [x] Long press the black bubble to show UIDebuggingInformationOverlay. (Apple's Private API, support iOS 10/11/12)

  • [x] Application memory usage and FPS.

  • [x] List all print() and NSLog() messages which have been written by developer in Xcode.

  • [x] List of all the network requests sent by the application.

  • [x] List crash errors.

  • [x] Share network details via email or copy to clipboard when you are in the Network Details page.

  • [x] Copy logs. (long press the text, then select all or select copy)

  • [x] Search logs by keyword.

  • [x] List application and device informations, including: version, build, bundle name, bundle id, screen resolution, device, iOS version

  • [x] List all sandbox folders and files, supporting to preview and edit.

  • [x] List HTML logs, including console.log(),console.debug(),console.warn(),console.error(),console. info(). (support both WKWebView and UIWebView).

  • [x] Support JSON and Google's Protocol buffers

Installation

CocoaPods

target 'YourTargetName' do
    use_frameworks!
    pod 'CocoaDebug', :configurations => ['Debug']
end

Carthage

github "CocoaDebug/CocoaDebug"

WARNING: Don't submit .ipa to AppStore which has been linked with the CocoaDebug.framework. This Integration Guide outline a way to use build configurations to isolate linking the framework to Debug builds only.

Usage

Swift

//AppDelegate.swift
 
#if DEBUG
    import CocoaDebug
#endif

#if DEBUG
    //If Use Google's Protocol buffers
    CocoaDebug.protobufTransferMap = [
                                     "your_api_keywords_1": ["your_request_protobuf_className_1", "your_response_protobuf_className_1"],
                                     "your_api_keywords_2": ["your_request_protobuf_className_2", "your_response_protobuf_className_2"],
                                     "your_api_keywords_3": ["your_request_protobuf_className_3", "your_response_protobuf_className_3"]
                                     ]
    CocoaDebug.enable()
#endif

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

//AppDelegate.m
 
#ifdef DEBUG
    @import CocoaDebug;
#endif

#ifdef DEBUG
    //If Use Google's Protocol buffers
    CocoaDebug.protobufTransferMap = @{
                                      @"your_api_keywords_1": @[@"your_request_protobuf_className_1", @"your_response_protobuf_className_1"],
                                      @"your_api_keywords_2": @[@"your_request_protobuf_className_2", @"your_response_protobuf_className_2"],
                                      @"your_api_keywords_3": @[@"your_request_protobuf_className_3", @"your_response_protobuf_className_3"]
                                     };
    [CocoaDebug enable];
#endif

More

#ifdef DEBUG
    [CocoaDebugTool logWithString:string];
    
    NSString *prettyJSON = [CocoaDebugTool logWithJsonData:data];

    NSString *prettyJSON = [CocoaDebugTool logWithProtobufData:data className:@"protobuf_className"];
#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.

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.

  • protobufTransferMap - Protobuf data transfer to JSON map. default value is nil.

GitHub