LLDebugTool - 便捷的IOS調試工具(支持Swift)

 LLDebugTool

LLDebugTool是一款針對開發者和測試者的調試工具,它能夠幫助你在非Xcode的狀況下,進行數據分析和操做。ios

LLDebugToolSwift是針對LLDebugTool的Swift擴展,它提供了LLDebugTool的Swift接口,LLDebugToolSwift會和LLDebugTool同步更新。git

若是你的項目是一個Objective-C項目,你可使用LLDebugTool,若是你的額項目是一個Swift項目或者包含Swift文件,你可使用LLDebugToolSwiftgithub

爲您的下一個項目選擇LLDebugTool,或者遷移到您現有的項目中——您會爲此感到驚喜!swift

Gif

ScreenShots

最近更新 (1.1.7)

支持Swift,更多Swift的用法能夠查看 LLDebugToolSwift

LLDebugToolSwift 是一個 LLDebugTool 的swift組件,它提供了一個LLog的swift類,用於在swift中使用log。網絡

更多的修改內容能夠查看Version 1.1.7 Projectapp

新增

  • 增長 LLog.swift,用於解決 LLDebugToolMacros 沒法在swift中使用。

更新

  • 更新 LLCrashHelper,如今 LLDebugTool 能夠正確的截獲signal信息。

我能用LLDebugTool作什麼?

  • 檢查網絡請求或者查看某些事件的日誌信息,而沒必要非在XCode運行下運行。這在解決測試人員的問題上頗有用。框架

  • 更輕鬆的篩選有用的信息。工具

  • 更輕鬆的處理偶發的問題。學習

  • 更輕鬆的分析崩潰緣由。測試

  • 更輕鬆的分享、預覽或刪除沙盒文件,這在開發階段很是有用。

  • 更輕鬆的觀察App的CPU,內存,FPS等信息。

添加 LLDebugTool 到你的項目中

CocoaPods

CocoaPods 是集成LLDebugTool的首選方式。

Objective - C
  1. 添加 pod 'LLDebugTool' , '~> 1.0.0' 到你的Podfile裏。若是隻想在Debug模式下使用,則添加pod 'LLDebugTool' , '~> 1.0.0' ,:configurations => ['Debug'] 到你的Podfile裏,詳細的配置方式能夠查看Wiki/如何僅在Debug環境中使用。若是你想要指定某個版本,能夠相似這樣使用 pod 'LLDebugTool' , '1.1.7' ,:configurations => ['Debug']
  2. 終端輸入pod install來進行集成。搜索不到LLDebugTool或者搜不到最新版本時,可先運行pod repo update,再執行pod install
  3. 在你須要使用LLDebugTool的文件裏添加#import "LLDebug.h",或者直接在pch文件中添加#import "LLDebug.h"
Swift
  1. 添加 pod 'LLDebugToolSwift' , '~> 1.0.0' 到你的Podfile裏。若是隻想在Debug模式下使用,則添加pod 'LLDebugToolSwift' , '~> 1.0.0' ,:configurations => ['Debug'] 到你的Podfile裏,詳細的配置方式能夠查看Wiki/如何僅在Debug環境中使用。若是你想要指定某個版本,能夠相似這樣使用 pod 'LLDebugToolSwift' , '1.1.7' ,:configurations => ['Debug']
  2. 必須在Podfile中添加 use_frameworks!
  3. 終端輸入pod install來進行集成。搜索不到LLDebugToolSwift或者搜不到最新版本時,可先運行pod repo update,再執行pod install
  4. 在你須要使用LLDebugTool的文件裏添加import LLDebugToolSwift

Carthage

Carthage 是一個分散的依賴管理器,它構建您的依賴併爲您提供framework框架。

Objective - C
  1. 要使用Carthage將LLDebugTool集成到Xcode項目中,請在Cartfile中指定它:

    github "LLDebugTool"

  2. 運行 carthage 來構建框架,並將構建的LLDebugTool.framework拖到Xcode項目中。

Swift
  1. 要使用Carthage將LLDebugToolSwift集成到Xcode項目中,請在Cartfile中指定它:

    github "LLDebugToolSwift"

  2. 運行 carthage 來構建框架,並將構建的LLDebugToolSwift.framework拖到Xcode項目中。

源文件

您能夠直接將名爲LLDebugTool文件夾的源文件添加到項目中。

Objective - C
  1. 下載最新的代碼版本或將存儲庫做爲git子模塊添加到您的git跟蹤項目中。
  2. 在Xcode中打開項目,而後拖拽名爲「LLDebugTool」的源文件夾到你的項目中。當提示Choose options for adding these files時,務必勾選Copy items if needed這項。
  3. 集成FMDB到項目中,FMDB是一個圍繞SQLite的Objective-C包裝器開源庫。
  4. 在你須要使用LLDebugTool的文件裏添加#import "LLDebug.h",或者直接在pch文件中添加#import "LLDebug.h"
Swift
  1. 下載最新的Objective-C代碼版本或將存儲庫做爲git子模塊添加到您的git跟蹤項目中。
  2. 下載最新的Swift擴展代碼版本或將存儲庫做爲git子模塊添加到您的git跟蹤項目中。
  3. 在Xcode中打開項目,而後拖拽名爲「LLDebugTool」和「LLDebugToolSwift」的源文件夾到你的項目中。當提示Choose options for adding these files時,務必勾選Copy items if needed這項。
  4. 集成FMDB到項目中,FMDB是一個圍繞SQLite的Objective-C包裝器開源庫。
  5. 在你須要使用LLDebugTool的文件裏添加import LLDebugToolSwift

如何使用

啓動

你須要在"application:(UIApplication * )application didFinishLaunchingWithOptions:(NSDictionary * )launchOptions"中啓動LLDebugTool,不然你可能會丟掉某些信息。

若是你想自定義一些參數,你須要在調用"startWorking"前配置這些參數。更詳細的配置信息請看LLConfig.h

  • 快速啓動

In Objective-C

#import "AppDelegate.h"
#import "LLDebug.h"

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // The default color configuration is green background and white text color. 

    // Start working.
    [[LLDebugTool sharedTool] startWorking];
    
    // Write your project code here.
    return YES;
}
複製代碼

In Swift

import LLDebugToolSwift

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // ####################### Start LLDebugTool #######################//
        // Use this line to start working.
        LLDebugTool.shared().startWorking()
        
        // Write your project code here.
        
        return true
    }
複製代碼
  • 使用自定義的配置啓動

In Objective-C

#import "AppDelegate.h"
#import "LLDebug.h"

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    //####################### Color Style #######################//
    // Uncomment one of the following lines to change the color configuration.
    // [LLConfig sharedConfig].colorStyle = LLConfigColorStyleSystem;
    // [[LLConfig sharedConfig] configBackgroundColor:[UIColor orangeColor] textColor:[UIColor whiteColor] statusBarStyle:UIStatusBarStyleDefault];
    
    //####################### User Identity #######################//
    // Use this line to tag user. More config please see "LLConfig.h".
    [LLConfig sharedConfig].userIdentity = @"Miss L";
    
    //####################### Window Style #######################//
    // Uncomment one of the following lines to change the window style.
    // [LLConfig sharedConfig].windowStyle = LLConfigWindowNetBar;

    //####################### Features #######################//
    // Uncomment this line to change the available features.
    // [LLConfig sharedConfig].availables = LLConfigAvailableNoneAppInfo;
    
    // ####################### Start LLDebugTool #######################//
    // Use this line to start working.
    [[LLDebugTool sharedTool] startWorking];
    
    return YES;
}
複製代碼

In Swift

import LLDebugToolSwift

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        
        //####################### Color Style #######################//
        // Uncomment one of the following lines to change the color configuration.
        // LLConfig.shared().colorStyle = .system
        // LLConfig.shared().configBackgroundColor(.orange, textColor: .white, statusBarStyle: .default)
        
        //####################### User Identity #######################//
        // Use this line to tag user. More config please see "LLConfig.h".
        LLConfig.shared().userIdentity = "Miss L";
        
        //####################### Window Style #######################//
        // Uncomment one of the following lines to change the window style.
        // LLConfig.shared().windowStyle = .netBar
        
        //####################### Features #######################//
        // Uncomment this line to change the available features.
        // LLConfig.shared().availables = .noneAppInfo
        
        // ####################### Start LLDebugTool #######################//
        // Use this line to start working.
        LLDebugTool.shared().startWorking()
        
        return true
    }
複製代碼

日誌

打印和保存一個日誌。 更多的log宏信息查看LLLogHelper.h

  • 保存日誌

In Objective-C

#import "LLDebug.h"

- (void)testNormalLog {
    // Insert an LLog where you want to print.
    LLog(@"Message you want to save or print.");
}
複製代碼

In Swift

import LLDebugToolSwift

    func testNormalLog() {
        // Insert an LLog where you want to print.
        LLog.log(message: "Message you want to save or print.")
    }

複製代碼
  • Save Log with event and level

In Objective-C

#import "LLDebug.h"

- (void)testEventErrorLog {
    // Insert an LLog_Error_Event where you want to print an event and level log.
    LLog_Error_Event(@"The event that you want to mark. such as bugA, taskB or processC.",@"Message you want to save or print.");
}
複製代碼

In Swift

import LLDebugToolSwift

    func testEventErrorLog() {
        // Insert an LLog_Error_Event where you want to print an event and level log.
        LLog.errorLog(message: "Message you want to save or print.", event: "The event that you want to mark. such as bugA, taskB or processC.")
    }
複製代碼

網絡請求

你不須要作任何操做,只須要調用了"startWorking"就能夠監控大部分的網絡請求,包括使用NSURLSession,NSURLConnection和AFNetworking。若是你發現某些狀況下沒法監控網絡請求,請打開一個issue來告訴我。

崩潰

你不須要作任何操做,只須要調用"startWorking"就能夠截獲崩潰,保存崩潰信息、緣由和堆棧信息,而且也會同時保存當次網絡請求和日誌信息。

App信息

LLDebugTool會監控app的CPU,內存和FPS。你能夠更便捷的查看app的各類信息。

沙盒

LLDebugTool提供了一個快捷的方式來查看和操做沙盒文件,你能夠更輕鬆的刪除沙盒中的文件/文件夾,或者經過airdrop來分享文件/文件夾。只要是apple支持的文件格式,你能夠直接經過LLDebugTool來預覽。

更多使用

  • 你能夠經過查看Wiki,得到更多幫助。
  • 你能夠下載並運行LLDebugToolDemoLLDebugToolSwiftDemo來發現LLDebugTool的更多使用方式。Demo是在XCode9.3,ios 11.3,cocoapods 1.5.0下運行的,若是有任何版本兼容問題,請告訴我。

要求

LLDebugTool在支持ios8+,而且須要使用ARC模式。使用到的框架已經包含在大多數Xcode模板中:

  • UIKit

  • Foundation

  • SystemConfiguration

  • Photos

  • malloc

  • mach-o

  • mach

  • QuickLook

  • objc

  • sys

結構

  • LLDebug.h 公用頭文件.

  • LLConfig 配置文件。

    用於自定義顏色、大小、標識和其餘信息。若是您想要配置任何東西,您須要關注這個文件。

  • LLDebugTool 工具文件。

    用於啓動和中止LLDebugTool,你須要看一下"LLDebugTool.h"這個文件。

  • Helper 輔助文件。

    若是你對功能的實現原理不感興趣,那麼能夠忽略這個文件夾。

    • LLAppHelper 用於監視應用程序的各類屬性。
    • LLCrashHelper 用於當App發生崩潰時,收集崩潰信息。
    • LLLogHelper 快速打印和保存日誌。
    • LLNetworkHelper 用於監視網絡請求。
    • LLSandboxHelper Sandbox Helper。用於查看和操做沙盒文件。
    • LLStorageManager Storage Helper。用於數據存儲和讀取。
  • UserInterface UI文件。

    若是你想要修改、查看或者學習UI方面的東西,你能夠查看一下這個文件夾。

    • Base 父類文件
    • Categories 類擴展
    • Others 不通用的控件
    • Resources 圖片資源
    • Sections 視圖控制器
    • Tool 工具

聯繫

  • 若是你須要幫助,打開一個issue。
  • 若是你想問一個廣泛的問題,打開一個issue。
  • 若是你發現了一個bug並能提供可靠的複製步驟,打開一個issue。
  • 若是你有一個功能請求,打開一個issue。
  • 若是你發現有什麼不對或不喜歡的地方,就打開一個issue。
  • 若是你有一些好主意或者一些需求,請發郵件(llworkinggroup@qq.com)給我。
  • 若是你想貢獻,提交一個pull request。

聯繫

更新日誌

能夠在 CHANGELOG 中找到每一個LLDebugTool版本的簡要總結。

相關文章
相關標籤/搜索