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.
To run the example project, clone the repo, and run pod install
from the Example directory first.
Sentinel is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'Sentinel'
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")
]
In this chapter, some of the most important pieces of the library will be introduced.
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.
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.
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.
To add the Sentinel to your project, install the library via CocoaPods 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)
Sentinel does not collect any user data. We have provided a privacy manifest file that can be included in your app.
Sentinel is available under the MIT license. See the license file for more information.
Maintained and sponsored by Infinum.
link |
Stars: 3 |
Last commit: 12 hours ago |
Released on: 07 Feb 2024
Detailed changelog: 1.1.2...1.2.0
EmailSenderTool
used for sending emails has been added to the Sentinel.
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics