Swift Markdown Kit · DOCS

Reference

Reference

Views and controllers

TypeUse
MarkdownRenderViewSwiftUI, one document.
MarkdownRenderViewControllerUIKit, one document.
MarkdownChatRenderViewSwiftUI, a whole conversation.
MarkdownChatRenderViewControllerUIKit, a whole conversation.
MarkdownChatRenderProxyImperative control of a SwiftUI chat view.
MarkdownRenderKitversion, bridgeVersion, licenseDiagnostics().

Document methods

render(_:) · renderStream(_:) · startStreaming() · appendChunk(_:isFinal:) · finishStreaming() · clear() · reload() · contentHeight · licenseStatus

Conversation methods

setMessages(_:) · appendMessage(_:) · updateMessage(_:) · appendChunk(_:to:isFinal:) · appendReasoningChunk(_:to:isFinal:) · finishReasoning(for:) · setReasoningExpanded(_:for:) · finishMessage(_:) · removeMessage(_:) · clear() · scrollToBottom(animated:) · contentHeight · licenseStatus

MarkdownRenderOptions

OptionDefaultMeaning
colorScheme.auto.auto, .light, .dark.
theme.system.system or .github, plus token overrides.
extensions[]Custom inline syntax.
interaction.automaticWho handles link and image taps.
isScrollEnabledtrueOff when embedding inside your own scroll view.
backgroundColor.clearRenderer background.
contentPadding16pt all roundInset between content and edges.
bottomGap0Extra space under the last block, for an overlaying composer.
markdownsee belowParser capabilities.
streamingMode.incremental.fullRerender re-renders everything on each flush.
longBlockStreaming.throttled.deferred holds a long block until it completes.
longBlockThreshold512Characters before the strategy applies.
baseFontSize16Before Dynamic Type scaling.
respectsDynamicTypetrueFollow the system text size.
minFontScale / maxFontScale0.85 / 1.6Clamp on the Dynamic Type multiplier.
heightChangeDebounceInterval0.08Debounce on height reporting while streaming.
copyText / copiedText / copyFailedTextlocalizedCode block copy button labels. Default to the reader's language — see Localization.

MarkdownRenderLocalization

The language the SDK draws its own strings in, and the strings themselves. Full detail in Localization.

MemberMeaning
language.automatic (default, follows the device), .english, .simplifiedChinese, .custom(_:).
availableLanguagesLocalization codes this build ships, e.g. ["en", "zh-Hans"].
codeCopy / codeCopied / codeCopyFailedCode block copy button, resolved.
messageCopy / messageCopied / messageRetry / messageEditMessage action accessibility labels, resolved.
reasoningThinking / reasoningCompleted / reasoningDurationReasoning fold headers, resolved.

MarkdownRenderOptions.MarkdownConfig

OptionDefault
allowRawHTMLfalse
linkifytrue
typographertrue
breaksfalse
taskListstrue
emojitrue
mathtrue
reasoningenabled

MarkdownChatRenderOptions

OptionDefaultMeaning
renderOptions—The document options above, applied to every message.
interaction.automaticShorthand for renderOptions.interaction.
reasoningenabledThe reasoning fold.
messageActionscopy onlyPer-message toolbar.
streamingPresentation.smooth.immediate shows each chunk as it lands.
autoScrollBehavior.nearBottom.always, .never.
preservesUserScrolltrueStop following once the reader scrolls up.
bottomThreshold96Points from the bottom that still count as "at the bottom".
messageSpacing14Points between messages.
maxMessageWidth.fullWidth of the reading column.
userMessageMaxWidth.fraction(0.82)Width of the user's own bubbles.
chunkCoalescingInterval1/30 sGather tokens before crossing into the web view; 0 disables.

Events

MarkdownRenderEvent for documents, MarkdownChatRenderEvent for conversations. The chat variant adds viewportChanged and messageAction, and wraps actions with the message id they came from.

EventFires when
.readyThe renderer finished loading and queued commands start running.
.rendered(height:)Exactly twice per content cycle: first paint, and the final flush.
.heightChanged(_)Height changed in between — streaming, image loads, Dynamic Type. Debounced while streaming.
.viewportChanged(_)Scroll position and whether the reader is near the bottom.
.messageAction(_)Copy, retry or edit tapped on a message.
.action(_)Everything below.
.error(_)A structured failure carrying a stable code.

Actions

Requests — nothing happens unless you act:

ActionMeaning
.linkTapped(URL)A link was tapped and interaction.links is .handledByHost.
.imageTapped(URL?)An image was tapped and interaction.images is .handledByHost.
.extensionTapped(name:action:value:)A custom inline extension was tapped.
.custom(name:payload:)An unrecognised bridge message.

Notifications — the SDK already acted:

ActionMeaning
.didOpenLink(URL)Opened in the in-app browser, or handed to the system for mailto/tel.
.didPresentImage(URL)The built-in viewer was presented.
.linkBlocked(url:scheme:)The scheme is not in allowedLinkSchemes; nothing was opened.
.codeCopied(text:language:)Copied to the pasteboard.
.codeCopyFailed(text:language:error:)Copy failed.
.reasoningToggled(isExpanded:)The reader opened or closed a reasoning fold.
.taskToggled(isChecked:text:)A task list checkbox changed.

Errors

MarkdownRenderError carries reason, a human-readable message, and a stable code suitable for logging.

codeMeaning
licenseMissingNo .smklicense in Copy Bundle Resources.
licenseInvalidWrong envelope format, bad signature, or malformed payload.
licenseUnknownSigningKeySigned by a key this SDK does not trust — usually a test license paired with a production build.
licenseWrongIssuerEnvironmentIssued by the sandbox issuer; a production SDK accepts production only.
licenseUnauthorizedTeamIdThe app's signing team does not match the license.
licenseTeamIdentifierUnavailableThe Team ID could not be read — expected on the Simulator.
licenseUnauthorizedBundleIdThe bundle identifier is not covered by the license.
expiredTrialLicenseA trial license past its validUntil.
sdkReleaseNotCoveredThis SDK build was released after the license's updatesUntil; renew to use it.
releaseMetadataMissingThe framework is missing its release metadata — a broken build.
resourceMissing / resourceInvalid / resourceKeyInvalid / resourceDecryptionFailedThe bundled render core could not be loaded.
webViewLoadFailedThe web view failed to load the renderer.
webContentProcessTerminatedWebKit reclaimed the content process; the SDK reloads and replays automatically.
renderFailed / serializationFailed / copyFailedA runtime operation failed.

Every license* code is a diagnostic, not a failure. Rendering continues; the build is badged. See Licensing.

Versioning

MarkdownRenderKit.version        // SDK version, e.g. "0.0.10"
MarkdownRenderKit.bridgeVersion  // native ↔ web message contract version

The framework ships with library evolution enabled. Within a major version, public declarations are only ever added — an app compiled against an earlier build keeps linking against a later one without being rebuilt.