Skip to main content

iOS host API

Quick reference​

APIBehavior
ReloUI()Create the runtime; register capabilities before sessions.
RemoteDocument(source:data:format:)Create a document; data defaults empty, format defaults 1.
runtime.session(document:)Validate and create a logical RemoteSession.
runtime.action(_:_:)Register a raw JSON or typed Decodable/Encodable async action.
runtime.binding(_:_:)Register a HostBinding.
RemoteViewController(session:sizing:)Attach using the sole UIKit renderer.
controller.update(sizing:theme:)Change measurement policy and optionally update appearance.
controller.detach()Release the UIKit attachment and preserve the logical session.
controller.imageLoaderSet a host implementation of the async RemoteImageLoading protocol.
ReloSwiftUI.RemoteView(session:sizing:theme:)Attach a retained session to UIKit from SwiftUI.
session.updateData(_:)Replace root data and retain compatible state.
session.reset(data:)Reset local state within the existing document.
session.replace(document:)Replace source and start a new document lifetime.
session.motionPolicysystem/reduced/off; default system.
session.onEvent / session.onErrorRoot output and diagnostic callbacks.
session.close()Permanently end the session and cancel pending work.

runtime.navigation is weak. Retain your router in the app host and implement supports(route:) if preflight should reject unavailable destinations. Register UIKit adapters on the ViewRuntime that backs ReloUI. Services that need write access to a HostBinding provide its setter. Call update(_:) to publish changes made by the host.

Minimal host​

import ReloUI

let runtime = ReloUI()
let session = try runtime.session(document: RemoteDocument(
source: "<Text text=\"Hello\" />"
))
let controller = RemoteViewController(session: session, sizing: .viewport)
// Embed controller using normal UIKit containment.
// When the destination is permanently removed:
session.close()

Ownership and platform requirements​

iOS 16 is the minimum target. ReloCore remains UIKit-free; ReloUIKit is the renderer. ReloSwiftUI hosts UIKit. Runtime/session UI mutation is main-actor owned. Detaching presentation need not close logical state; retain the session for the destination lifetime.

Register actions, bindings, navigation, and native adapters before creating sessions. Session registrations are snapshotted. The app owns authentication, persistence, transport, and fallback UI. XML component definitions still need assembly even when Components host services are installed.

iOS integration guide · Current source · Document contract