StanwoodDebugger 1.3

StanwoodDebugger 1.3

Tal Zion 维护。



 
依赖项
Pulsator>= 0
StanwoodCore>= 0
SourceModel>= 0
Toast-Swift~> 4.0.1
 

  • 作者:
  • stanwood

StanwoodDebugger 框架

Swift 版本 iOS 10+ Maintainability Build Status 由于软件开发的特点,iOS 应用的调试和测试可能是一项相当长的任务。 StanwoodDebugger 工具提供有关分析、错误、日志、网络和界面测试的丰富信息,以简化此过程。

Demo StanwoodDebugger

目录

作者

Tal Zion [email protected]

安装

pod 'StanwoodDebugger', :configurations => ['Debug'] # Make sure to only use StanwoodDebugger for development only.

使用方法

#if DEBUG
import StanwoodDebugger
#endif

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    #if DEBUG
    lazy var debugger: StanwoodDebugger = StanwoodDebugger()
    #endif

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

        #if DEBUG
        debugger.isEnabled = true
        #endif
    }
}

其他选项

debugger.enabledServices: [Service] = [.logs, .errors] /// The services you would like to enable. Default is se to `allCases`
debugger.tintColor = .red /// Change the tint color
debugger.errorCodesExceptions = [4097] /// Add error code exceptions
debugger.isEnabled = true
debugger.isShakeEnabled = true // Defaults to `true`. When this is `true`, shaking the device will enable/disable the Debugger

添加日志

分析

选项1。

设置您的跟踪负载

public func payload() -> [String:String] {

    var payload: [String:String] = ["eventName": eventName]

    if let itemId = itemId {
        payload["itemId"] = itemId
    }

    if let category = category {
        payload["category"] = category
    }

    if let contentType = contentType {
        payload["contentType"] = contentType
    }

    if let screenName = screenName {
        payload["screenName"] = screenName
    }

    let dateFormatter = DateFormatter()
    dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZ"

    payload["createdAt"] = dateFormatter.string(from: Date())

    return payload
}

发布到

func post(_ payload: [String:String]) {
    let notificationCentre = NotificationCenter.default
    let notification = Notification.init(name: Notification.Name(rawValue: "io.stanwood.debugger.didReceiveAnalyticsItem"), object: nil, userInfo: payload)
    notificationCentre.post(notification)
}
选项2。

使用 StanwoodAnalytics 作为您的跟踪框架

#if DEBUG
analyticsBuilder = analyticsBuilder.setDebuggerNotifications(enabled: true)
#endif

网络

StanwoodDebugger 默认与 URLSessiosn.shared 一起使用,并且请求将被免费记录。您还可以注册自定义配置。

let configuration = URLSessionConfiguration.waitsForConnectivity

debugger.regsiter(custom: configuration)

/// Use with URLSession || any networking libraries such as Alamofire and Moya
let session = URLSession(configuration: configuration)

Module

错误

StanwoodDebugger 默认将记录 NSError。要添加记录异常}

debugger.errorCodesExceptions = [4097] /// Add error code exceptions

日志

StanwoodDebugger 默认记录 print && debugPrint

配置

  1. 创建一个新的 Bridging-Header 文件并添加 -DEBUG 后缀

logs-1

  1. 导入 StanwoodDebugger
@import StanwoodDebugger;

注意:确保在主头文件中添加了任何其他导入的库

  1. 在构建设置的相关配置中将 Bridging-Header-DEBUG.h 设置好。

logs-3

崩溃

StanwoodDebugger 默认将记录 SignalNSException 崩溃。

许可

StanwoodDebugger 采用 MIT 许可。更多信息请参见 LICENSE 文件。

变更日志

每个StanwoodDebugger版本简要总结可在变更日志中找到。