Library / SDK
kostub/iosMath avatar
kostub/iosMath

iosMath: Native LaTeX Equation Rendering for iOS and macOS

Beautiful math equation rendering on iOS and MacOS

1,474 stars259 forksObjective-CMIT

At a glance

What is it?
iosMath renders LaTeX-style equations in native iOS and macOS views without a WebView. It suits app developers who need native display controls, but its iOS 13 and macOS 10.15 minimums and LaTeX subset should be checked before adoption.
Who is it for?
Adopt iosMath when an Apple-platform app needs equations rendered directly in UIKit, AppKit or a SwiftUI wrapper rather than in browser-based math. Do not choose it if a WebView-based tool is required, the app supports platform versions below iOS 13 or macOS 10.15, or the expected formulas depend on undocumented LaTeX behavior.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 62 days ago.
What is it written in?
Mainly Objective-C, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on October 22, 2026, and from our analysis. They are not legal advice.

Editorial analysis

Why iosMath Exists in Native Apple Interfaces

iosMath addresses the need to display mathematical formulae inside native iOS and macOS applications. Its primary rendering surface is `MTMathUILabel`, described by the README as a `UIView` or `NSView` subclass. An application supplies a LaTeX string through the `latex` property and adds the resulting label to its view hierarchy.

The intended audience is developers building equation-heavy educational, scientific, technical or reference applications where a web page is an undesirable presentation layer. The README explicitly says that iosMath typesets LaTeX formulae using the same typesetting rules as TeX and does not require a WebView. It also characterizes the library as faster than a `UIWebView`, although no benchmark data or test configuration accompanies that claim.

This is a display library, not a full LaTeX compiler. The documented formula support includes algebraic equations, fractions, roots, exponents, subscripts, calculus notation, large operators, matrices, alignment, colors, accents and several font styles. That range covers common presentation needs, but users should not interpret the package as an unrestricted LaTeX environment. The documentation does not describe document processing, bibliography, cross-references or packages such as TikZ.

How iosMath Turns LaTeX into a Native View

The central data flow is intentionally short. Application code creates `MTMathUILabel`, assigns a string to `label.latex`, and inserts the label into an existing view. According to the README, the library parses and typesets that input using TeX rules, then renders the equation through the native view subclass. No HTML conversion, JavaScript runtime or `WKWebView` is part of the documented path.

Rendering remains configurable after the initial input. The `mode` property selects Display mode, described as equivalent to `$$` in LaTeX, or Text mode, equivalent to `$`. Display mode is the default. The label also exposes font size, math font, text color, text alignment and content insets. Individual colors can be changed through nodes in `displayList`, which gives applications a finer targeting mechanism than a single label-wide color.

The package exposes Objective-C APIs while allowing Swift clients to import it as a Swift package. This is relevant to integration design. Objective-C applications can use `MTMathUILabel` directly, Swift applications can use the same class, and SwiftUI applications need a small bridge through `UIViewRepresentable` or `NSViewRepresentable`. The repository includes platform-specific test and example directories, but the documented public path remains the label and its configuration properties.

Installing iosMath and Rendering the First Formula

The README distributes iosMath through Swift Package Manager. In Xcode, its stated route is `File → Add Package Dependencies…`, followed by entry of the repository URL. For a Swift package target, declare the dependency and attach `iosMath` to the target:

swift
dependencies: [
    .package(url: "https://github.com/kostub/iosMath.git", from: "2.1.0"),
],
targets: [
    .target(
        name: "YourTarget",
        dependencies: ["iosMath"]
    ),
]

This snippet gives the package a version range starting at `2.1.0`. The repository also lists releases `2.4.0`, `2.3.1` and `2.5.0`, but the documented example does not prescribe a different minimum version.

After installation, create the label, assign the quadratic formula and add it to a view. The renderer should display the fraction, radical, plus-or-minus symbol and superscripts within the label:

swift
import iosMath

let label = MTMathUILabel()
label.latex = #"x = \frac{-b \pm \sqrt{b^2-4ac}}{2a}"#
view.addSubview(label)

The example uses UIKit terminology, while `MTMathUILabel` also serves as the `NSView` implementation on macOS. For SwiftUI, the supplied pattern forwards changes made through `updateUIView` or `updateNSView` to the label's `latex` property:

swift
import SwiftUI
import iosMath

struct MathView: UIViewRepresentable {
    let latex: String
    func makeUIView(context: Context) -> MTMathUILabel { MTMathUILabel() }
    func updateUIView(_ view: MTMathUILabel, context: Context) {
        view.latex = latex
    }
}

The repository provides `SwiftMathExample/MathLabel.swift` for a cross-platform wrapper with font, color and alignment support, so applications do not have to build all presentation configuration into the minimal wrapper.

Platform, Font and Formula Constraints

The supported platforms are narrower than older AppKit or UIKit deployments may require. iosMath requires iOS 13 or later and macOS 10.15 or later. Its documented Apple framework dependencies are Foundation, CoreGraphics, QuartzCore and CoreText, plus UIKit on iOS or AppKit on macOS. Those minimums are concrete adoption checks because they determine whether the package can enter an existing application target.

Formula coverage is broad but bounded. The README names fractions, continued fractions, exponents, subscripts, trigonometric formulae, square and n-th roots, limits, derivatives, integrals, large operators, scalable delimiters, Greek characters, combinatorics, geometry symbols, ratios, percentages, spacing, overlines, underlines, accents, matrices, equation alignment, font styles, common symbols and colors. It does not claim support for arbitrary LaTeX packages or every command accepted by a desktop TeX distribution.

The default font is Latin Modern Math at 20pt, and left alignment is the default. Eight bundled fonts are listed, including XITS Math, STIX Two Math, Fira Math and Noto Sans Math. Any OTF math font can be used according to the README. Older per-font convenience methods were removed, so integrations must use `font(withName:size:)` with a named constant. This removal matters during upgrades because older application code may need to replace convenience-method calls rather than update a version number alone.

SwiftUI is supported through wrapper types, but iosMath itself is not documented as a SwiftUI `View`. Teams should treat the wrapper as required integration code and inspect sizing, alignment and update behavior in their particular parent view.

Native Rendering Compared with MathJax and KaTeX

The README positions iosMath as a native counterpart to MathJax and KaTeX. The meaningful difference is the rendering environment and integration surface. MathJax and KaTeX operate in web contexts, where formula markup is processed for browser output. iosMath renders into a native `UIView` or `NSView`, exposing properties such as `latex`, `fontSize`, `textColor`, `textAlignment` and `contentInsets` directly to Apple-platform application code.

That design removes the documented WebView dependency and allows native controls to participate in layout and styling. For SwiftUI, however, access still passes through `UIViewRepresentable` or `NSViewRepresentable`. The distinction is therefore not that web libraries cannot be embedded in Apple apps, but that iosMath exposes formula presentation as native view content rather than requiring a browser-based rendering pipeline.

MathJax and KaTeX may be more natural for teams whose equations live in web content, shared web components or browser-oriented publishing workflows. Those comparative deployment models are not described in the repository, so the documentation does not establish which parser has broader LaTeX compatibility. For iosMath specifically, evaluate its documented command list and bundled examples rather than assuming parity with the full TeX ecosystem.

Maintenance, Release Cadence and MIT Obligations

The repository is not archived. Its last push was on 2026-08-21, less than two months before 2026-10-17, and the listed releases include `2.5.0` dated 2026-07-13, `2.4.0` dated 2026-06-30 and `2.3.1` dated 2026-06-07. These dates indicate recent project activity, but the README does not publish a support policy or a compatibility matrix for each release.

Upgrading requires more than checking that Swift Package Manager resolves. The removal of `latinModernFontWithSize:`, `xitsFontWithSize:` and `termesFontWithSize:` is a documented API migration. Integrations should also check custom-font loading, SwiftUI update callbacks and formula appearance after changing packages. The release list does not state migration notes for versions `2.3.1`, `2.4.0` or `2.5.0`, so `CHANGELOG.md` is the repository file to inspect for version-specific changes.

The repository identifies the project as MIT-licensed and includes a `LICENSE` file. The MIT license permits use, modification, distribution and sublicensing under its conditions, while requiring preservation of its copyright and license notice. This is a statement of repository metadata, not legal advice. Applications still need to review the actual `LICENSE` text and comply with its notice and disclaimer provisions.

Editorial conclusion

Adopt iosMath when an Apple-platform app needs equations rendered directly in UIKit, AppKit or a SwiftUI wrapper rather than in browser-based math. Do not choose it if a WebView-based tool is required, the app supports platform versions below iOS 13 or macOS 10.15, or the expected formulas depend on undocumented LaTeX behavior. Verify formula coverage in the project examples first, then confirm that the selected display mode, font and color settings match the intended presentation.

Frequently asked questions

Which platforms and minimum versions does iosMath support?

iosMath supports iOS 13 and later and macOS 10.15 and later. It uses UIKit on iOS and AppKit on macOS.

Does iosMath require a WebView to render equations?

No. The README states that iosMath renders LaTeX formulae directly in a `UIView` or `NSView` subclass and does not require a WebView.

How can I use iosMath with SwiftUI?

Wrap `MTMathUILabel` with `UIViewRepresentable` on iOS or `NSViewRepresentable` on macOS. The wrapper assigns the supplied formula to the label's `latex` property during its update method.

Official sources

  1. Issues
  2. kostub/iosMath on GitHub
  3. License: MIT
  4. README
  5. Releases
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/kostub-iosmath.svg)](https://hysenlabs.com/projects/kostub-iosmath)

Was this useful?