Latest 0.3.0-beta
Homepage https://github.com/HituziANDO/LoggingViewKit
License MIT
Platforms ios 9.3, requires ARC
Authors

LoggingViewKit is a library tracking a user operation.

Include in your iOS app

CocoaPods

LoggingViewKit is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "LoggingViewKit", "0.2.3"

Manual Installation

  1. Download latest LoggingViewKit
  2. Drag & Drop LoggingViewKit.framework into your Xcode project
  3. Add -all_load to Build Settings > Linking > Other Linker Flags

Supported View

  • Button
  • Label
  • SegmentedControl
  • Slider
  • Stepper
  • Switch
  • View

Quick Usage

  1. Set LGV UI class in the storyboard

    screenshot1

  2. Set arbitrary name to loggingName

    screenshot2

    [NOTE] Recommend setting a unique name.

  3. Select On to record the view

    [NOTE] If you select Off or Default, the view is not target to record.

  4. Import framework

    Swift

    import LoggingViewKit

    Objective-C

    #import <LoggingViewKit/LoggingViewKit.h>
  5. Start recording

    Swift

    @UIApplicationMain
    class AppDelegate: UIResponder, UIApplicationDelegate {
    
        ...
    
        func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    
            LGVLoggingViewService.shared().startRecording()
    
            return true
        }
    
        ...
    
    }

    Objective-C

    @implementation AppDelegate
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
        [[LGVLoggingViewService sharedService] startRecording];
    
        return YES;
    }
  6. Stop recording

    Swift

    LGVLoggingViewService.shared().stopRecording()

    Objective-C

    [[LGVLoggingViewService sharedService] stopRecording];
  7. Read all logs

    Swift

    let logs = LGVLoggingViewService.shared().allLogs()

    Objective-C

    NSArray<LGVLog *> *logs = [[LGVLoggingViewService sharedService] allLogs];
  8. Delete all logs

    Swift

    LGVLoggingViewService.shared().deleteAllLogs()

    Objective-C

    [[LGVLoggingViewService sharedService] deleteAllLogs];

More info, see my sample project.

Sample Log

LoggingViewKit records the following log.

{
    ID = 47;
    absoluteClickX = "124.3333282470703";
    absoluteClickY = "189.6666564941406";
    clickX = "108.3333282470703";
    clickY = "145.6666564941406";
    createdAt = "2018-12-25 23:02:13 +0000";
    info =     {
        newValue = 2;
    };
    key = "7F34859D-2164-4B4B-B896-EA9D3D826C92";
    name = SampleSegmentedControl;
}

Utility

Dump View Hierarchy

LoggingViewKit can dump the hierarchy of specified view to Xcode console. The sample log is following.

2019-04-02 12:11:59.876292+0900 LoggingViewSwiftSample[8616:19026371] ===LGVUtility ViewHierarchy===
UIView
  LGVView(loggingName: (null))
    LGVButton(loggingName: SampleButton)
    LGVSwitch(loggingName: SampleSwitch)
      UISwitchModernVisualElement
        UIView
          UIView
        UIView
          UIView
        UIView
          UIImageView
          UIImageView
        UIImageView
    LGVSegmentedControl(loggingName: SampleSegmentedControl)
      UISegment
        UISegmentLabel
        UIImageView
      UISegment
        UISegmentLabel
        UIImageView
      UISegment
        UISegmentLabel
        UIImageView
      UISegment
        UISegmentLabel
        UIImageView
    LGVStepper(loggingName: SampleStepper)
      _UIStepperButton
      _UIStepperButton
      UIImageView
    LGVLabel(loggingName: SampleLabel)
    LGVView(loggingName: SampleView)
      LGVButton(loggingName: TestButton)
    LGVSlider(loggingName: SampleSlider)

Usage

Swift

override func viewDidLoad() {
    super.viewDidLoad()

    #if DEBUG
    // Dumps hierarchy of the root view.
    LGVUtility.printViewHierarchy(view)
    #endif
}

[NOTE] Recommend that you enclose with #if DEBUG ~ #endif. Then LoggingViewKit dumps logs only in Debug build.

How to Enable DEBUG Flag:

  1. Open Build Settings > Swift Compiler – Custom Flags > Other Swift Flags section
  2. Add -DDEBUG flag to Debug row

Objective-C

- (void)viewDidLoad {
    [super viewDidLoad];

#ifdef DEBUG
    // Dumps the hierarchy of the root view.
    [LGVUtility printViewHierarchy:self.view];
#endif
}

[NOTE] Recommend that you enclose with #ifdef DEBUG ~ #endif. Then LoggingViewKit dumps logs only in Debug build.

Latest podspec

{
    "name": "LoggingViewKit",
    "version": "0.3.0-beta",
    "summary": "LoggingViewKit is simple view logging library.",
    "description": "LoggingViewKit is a library tracking a user operation.",
    "homepage": "https://github.com/HituziANDO/LoggingViewKit",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Hituzi Ando": "[email protected]"
    },
    "platforms": {
        "ios": "9.3"
    },
    "source": {
        "git": "https://github.com/HituziANDO/LoggingViewKit.git",
        "tag": "0.3.0-beta"
    },
    "source_files": "LoggingViewKit/LoggingViewKit/**/*.{h,m}",
    "exclude_files": [
        "LoggingViewKit/build/*",
        "LoggingViewKit/Framework/*",
        "Sample/*"
    ],
    "requires_arc": true
}

Pin It on Pinterest

Share This