Coder Social home page Coder Social logo

ios-sentinel's Introduction

Sentinel

Sentinel

Build Status Version License Platform

Description

Sentinel is a simple library that gives developers the possibility to configure one entry point for every debug tool. The idea of Sentinel is to give the ability to developers to configure a screen with multiple debug tools which are available via some event (e.g. shake, notification).

Sentinel has a tab bar that contains five screens. Three of those aren't configurable, and two of them are. The first screen is the Device screen which allows the user to look into some of the device-specific information. The second screen is the Application screen which allows the user to look into some of the application-specific information from the info.plist. The third, the first configurable screen, is the Tools screen. Tools screen allows you to add as much Tool object as your heart desires which can be used by the user to find out some specific information. The fourth, last configurable screen, is the Preferences screen. Preferences screen allows you to add options that allow or deny some activity inside the app. The last, but not the least, is the Performance screen which contains performance-specific information. Later on, we'll explain how you can configure those screens.

This library supports both Swift and Objective-C.

Table of contents

Requirements

  • iOS 10 and above
  • Xcode 10 and above

Getting started

Installation

CocoaPods

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

pod 'Sentinel'

Swift Package Manager

If you are using SPM for your dependency manager, add this to the dependencies in your Package.swift file:

dependencies: [
    .package(url: "https://github.com/infinum/ios-sentinel.git")
]

To add the Sentinel to your project, install the library as instructed above. After that, define Sentinel configuration with mandatory parameters and call Sentinel.shared.setup: in the AppDelegate method application(_:didFinishLaunchingWithOptions:).

let configuration = Sentinel.Configuration(
    sourceScreenProvider: SourceScreenProviders.default,
    trigger: Triggers.shake,
    tools: [
        GeneralInfoTool(),
        UserDefaultsTool(),
        LoggieTool(),
    ],
    preferences: [
        OptionSwitchItem(
            name: "Analytics",
            setter: { AppSwitches.analyticsEnabled = $0 },
            getter: { AppSwitches.analyticsEnabled },
            userDefaults: .standard,
            userDefaultsKey: "com.infinum.sentinel.optionSwitch.analytics"
        )
    ]
)

Sentinel.shared.setup(with: configuration)

Usage

Basics

Sentinel is the main class used to setup the Sentinel which will be used in the application. The Sentinel object can configured via setup: method by Configuration object.

Configuration

To be able to configure the Sentinel object, the Configuration object is introduced. This object contains multiple objects which define general Sentinel behaviour. The inputs which this object needs are; trigger, sourceScreenProvider, tools, and preferences.

The trigger object is a type of Trigger which defines on which event the Sentinel will be triggered. Currently, three types of are supported; ShakeTrigger, ScreenshotTrigger, NotificationTrigger. New triggers can be added as well, just by conforming the Trigger protocol.

The sourceScreenProvider object is a type of SourceScreenProvider which should provide a view controller from where will Sentinel be presented. Currently, one type is supported; default.

The tools object is an array of Tool objects. Tool objects represent tools which will be available from Sentinel. There are multiple tools already supported by the library, but custom tools can be created and added to the Sentinel.

The last, but not the least, is the preferences object which is an array of OptionSwitchItem objects. OptionSwitchItem is used to allow the user to switch of some of the preferences which are contained in the app. e.g. The app supports Analitycs and you can add an OptionSwitchTool which will be shown on the Preferences screen and the user can turn it off if he doesn't want it.

Custom tools

To be able to create a custom tool that will be available through the Sentinel, a new class should be created which conforms the Tool protocol. This protocol is defined as:

public protocol Tool {
    var name: String { get }
    func presentPreview(from viewController: UIViewController)
}

Based on this, only name should be provided as well as presentPreview: method which will present the tool view controller from the sourceScreenProvider view controller defined in the Sentinel configuration.

A common custom tool that might be needed is Pulse network logger. It can be defined in the following way:

class PulseTool: Tool {
    var name: String { "Pulse" }

    func presentPreview(from viewController: UIViewController) {
        let pulse = UIHostingController(rootView: ConsoleView())
        let pulseNavigation = UINavigationController(rootViewController: pulse)
        viewController.present(pulseNavigation, animated: true)
    }
}

Contributing

We believe that the community can help us improve and build better a product. Please refer to our contributing guide to learn about the types of contributions we accept and the process for submitting them.

To ensure that our community remains respectful and professional, we defined a code of conduct that we expect all contributors to follow.

We appreciate your interest and look forward to your contributions.

License

Copyright 2024 Infinum

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Credits

Maintained and sponsored by Infinum.

ios-sentinel's People

Contributors

nikolamajcen avatar zvonimirmedak avatar milos-o avatar antonijo2307 avatar jabou avatar truba avatar jcavar avatar andrija-ostojic avatar goranbrl avatar ilucijabalja 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.