Droar是一个模块化、单行安装调试窗口。
概览
Droar背后的理念很简单:在应用程序部署阶段,直接将应用程序配置(例如从模拟到实况、快速登录到QA凭证、更改http环境等)写入和发送至生产代码。Droar通过将快速配置归组到一个地方,并在一个工具下解决此问题。
安装
Droar可通过CocoaPods获取。要安装,只需将以下行添加到您的Podfile中
pod "Droar"
开始
要开始使用Droar,请在您的应用程序代理的didFinishLaunchingWithOptions
方法中添加以下内容
import Droar
...
if nonProductionEnvironment {
Droar.start()
}
要打开,只需从屏幕的最右侧开始滑动即可。
配置
添加自己的旋钮(表格部分)
在Droar中添加旋钮有两种方式
静态旋钮
静态旋钮将始终出现在Droar中。只需将一个新类或现有类符合 DroarKnob
,并使用 Droar.register(DroarKnob)
来注册其实例。
动态旋钮
动态旋钮是符合 DroarKnob
的 UIViewController
实例。当Droar出现时,它将遍历主窗口的视图控制器层次结构,找到当前活动/可见的 UIViewController
,以查看它们是否符合 DroarKnob
。
不需要将视图控制器注册为静态旋钮。只需符合 DroarKnob
,如果在该屏幕上打开Droar,Droar将从中提取信息。
如果将 UINavigationController
、UITabBarViewController
等符合 DroarKnob
(并且目前可见/活动),则Droar将从中以及其活动/可见的视图控制器中提取信息。
DroarKnob
接口
@objc public protocol DroarKnob {
// Perform any setup before this knob loads (Register table cells, clear cached data, etc)
@objc optional func droarKnobWillBeginLoading(tableView: UITableView?)
// Title for this knob. If title matches existing knob, they will be combined
@objc func droarKnobTitle() -> String
// The positioning and priorty for this knob
@objc func droarKnobPosition() -> PositionInfo
// The number of cells for this knob
@objc func droarKnobNumberOfCells() -> Int
// The cell at the specified index. There are many pre-defined cells, just use Droar<#type#>Cell.create(), or create your own.
@objc func droarKnobCellForIndex(index: Int, tableView: UITableView) -> DroarCell
// Indicates the cell was selected. This will not be called if `UITableViewCell.selectionStyle == .none`
@objc optional func droarKnobIndexSelected(tableView: UITableView, selectedIndex: Int)
}
激活手势
要配置打开Droar的手势,请使用Droar
的《setGestureType
》方法。
默认控件
您可以使用Droar
的《registerDefaultKnobs
》方法来控制显示哪些默认部分。如果未调用此方法,则将显示所有默认控件。
插件
netfox-Droar
netfox是一个轻量级的、一行代码配置的iOS/OSX网络调试库。
FBMemoryProfiler-Droar
FBMemoryProfiler是一个iOS库,它提供了使用FBAllocationTracker和FBRetainCycleDetector查看内存中对象的开发工具。
作者
Nathan Jangula,Myriad Mobile,[email protected]
许可证
Droar遵从MIT许可协议。有关更多信息,请参阅LICENSE文件。