libmoss
runtime and exposes an idiomatic async/await API. Documents are embedded
and queried on-device, with optional cloud sync.
Requirements
- iOS 15+
- Xcode 15+
- Apple Silicon for the simulator (the SDK ships arm64 device + simulator slices)
Install
Add the package in Xcode via File ▸ Add Package Dependencies… and enterhttps://github.com/usemoss/moss, or declare it in Package.swift:
Moss.xcframework from the
GitHub release and verifies its checksum.
Two ways to search
The Swift SDK exposes two entry points:MossClient- the entry point. Construct it with your credentials, open sessions, and track push jobs.MossSession- an on-device index. Embed and query documents locally with no network calls, persist to disk, and sync to the cloud withpushIndex/loadIndex.
Indexing & sync
Indexes are created locally: open a session, calladdDocs, and the
documents are embedded and stored on-device - no network required.
To share an index across devices or back it up, sync it through the cloud:
- Push -
MossSession.pushIndex()publishes the local index to the cloud. - Pull -
MossSession.loadIndex(_:)hydrates a fresh session from a cloud index.
loadIndex is a one-time pull, so re-pull to
pick up later changes; continuous auto-sync - keeping a loaded index current
automatically - is also available if you’d rather not re-pull by hand.
Quick start
Build an index on-device, push it to the cloud, then load it back:Models
The on-device embedding model defaults tomoss-litelm on iOS. Pass
"custom" as the session modelId to supply your own pre-computed embeddings
via DocumentInfo.embedding.
Preparing documents
A few guidelines for the best retrieval quality and a compact index:- Document size - aim for roughly 100-250 tokens of text per document. Split long content (a chapter, a transcript) into focused chunks rather than one large document.
- Metadata - metadata is free-form
[String: String]. Put anything you’ll filter on (category, ids, coordinates) here - see the Querying guide.
Cross-platform
All Moss SDKs - Swift (iOS), Python, and JavaScript - are interoperable and read the same indexes. An index built or pushed from one SDK can be loaded and queried from another.Reference
- Classes - MossClient, MossSession
- Guides - Querying (hybrid search + metadata filtering), Custom Authenticator
- Types - DocumentInfo, QueryOptions, SearchResult, and more
Example app
A complete SwiftUI sample app is inexamples/ios.