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.
- iOS 10 and above
- Xcode 10 and above
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")
]
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)
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.
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)
}
}
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.
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.
Maintained and sponsored by Infinum.