Giter Club home page Giter Club logo

stanwood_debugger_ios's Introduction

StanwoodCore framework

Swift Version iOS 10+

Debugging and testing iOS applications can be quite a long task due to the nature of Software Development. StanwoodDebugger tool provides reach information on Analytics, Errors, Logging, Networking, and UITesting to simplify this process.

Demo StanwoodDebugger

Table of contents

Author

Tal Zion [email protected]

Installation

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

Usage

#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
    }
}

Other options

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

Adding logs

Analytics

Option 1.

Set up your tracking payload:

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
}

Post it to:

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)
}
Option 2.

Use StanwoodAnalytics as your tracking framework

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

Networking

StanwoodDebugger works by default with URLSessiosn.shared and request are beeing logged for free. You can also register a custom condiguration:

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

Error

StanwoodDebugger will log NSError by default. To add log exceptions:

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

Logs

StanwoodDebugger will log print && debugPrint by default.

Configuration:

  1. Create a new Bridging-Header file and add -DEBUG suffix

logs-1

  1. Import StanwoodDebugger
@import StanwoodDebugger;

Note: Make sure to add any other imported libraries from your main header file

  1. Set Bridging-Header-DEBUG.h in the relevant configurations in the build settings.

logs-3

Crashes

StanwoodDebugger will log Signal and NSException crashes by default.

Licence

StanwoodDebugger is under MIT licence. See the LICENSE file for more info.

Changelog

A brief summary of each StanwoodDebugger release can be found in the CHANGELOG.

stanwood_debugger_ios's People

Contributors

talezion avatar lukasz-lenkiewicz avatar ronanociosoig avatar

Watchers

24 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.