Carthage compatible

RIBsTreeViewer (RIBs树查看器)

在浏览器上实时查看已连接的 RIBs 树

演示 (Demo)

使用库

XCFramework

将 XCFramework 添加到你的项目。

./Products/RIBsTreeViewerClient.xcframework

CocoaPods

不支持 CocoaPods,因为 RIBs 没有提供最新的 PodSpec,这使得难以解决依赖关系。

Carthage

github "srea/RIBsTreeViewerClient"
$ carthage update --platform iOS --no-use-binaries

构建阶段


Carthage CopyFrameworks (仅限 DEBUG 模式)

 if [ ${CONFIGURATION%%-*} == "Debug" ]; then
    /usr/local/bin/carthage copy-frameworks
 fi

基本设置

@UIApplicationMain
public class AppDelegate: UIResponder, UIApplicationDelegate {

    private var ribsTreeViewer: RIBsTreeViewer? = nil
    
    public func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        let window = UIWindow(frame: UIScreen.main.bounds)
        self.window = window

        let result = RootBuilder(dependency: AppComponent()).build()
        let launchRouter = result.launchRouter
        self.launchRouter = launchRouter
        urlHandler = result.urlHandler
        launchRouter.launch(from: window)
        startRIBsTreeViewer(launchRouter: launchRouter)
        return true
    }
}
// MARK: - RIBsTreeViewer

#if DEBUG
import RIBsTreeViewerClient

extension AppDelegate {
    private func startRIBsTreeViewer(launchRouter: Routing) {
        if #available(iOS 13.0, *) {
            ribsTreeViewer = RIBsTreeViewerImpl.init(router: launchRouter,
                                                     options: [.webSocketURL("ws://0.0.0.0:8080"),
                                                               .monitoringIntervalMillis(1000)])
            ribsTreeViewer?.start()
        } else {
            // RIBsTreeViewer is not supported OS version.
        }
    }
}
#endif

安装

$ npm install yarn

启动 WebSocket 服务器

$ npx yarn install
$ node index.js

打开页面。

$ npx yarn install
$ npx webpack
$ open ./public/index.html