Add license and README, update Package.swift for binary target

Seto Elkahfi committed Apr 3, 2026 at 10:32 UTC 59323041008cdf19c47e4f6cd9ebb28b738e4bf9
3 files changed +180 -2
LICENSE new
+21
@@ -0,0 +1,21 @@
1 +MIT License
2 +
3 +Copyright (c) 2026 Onde Inference
4 +
5 +Permission is hereby granted, free of charge, to any person obtaining a copy
6 +of this software and associated documentation files (the "Software"), to deal
7 +in the Software without restriction, including without limitation the rights
8 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 +copies of the Software, and to permit persons to whom the Software is
10 +furnished to do so, subject to the following conditions:
11 +
12 +The above copyright notice and this permission notice shall be included in all
13 +copies or substantial portions of the Software.
14 +
15 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 +SOFTWARE.
Package.swift
+22 -2
@@ -1,7 +1,25 @@
1 // swift-tools-version:5.5
2 -import Foundation
2 import PackageDescription
3
4 +// ─────────────────────────────────────────────────────────────────────────────
5 +// LOCAL DEVELOPMENT
6 +//
7 +// When working on the Onde Rust crate locally, swap the url-based binary
8 +// target below to a path-based one pointing at your local XCFramework:
9 +//
10 +// name: "OndeFramework"
11 +// path: "./../onde/sdk/Onde/OndeFramework.xcframework"
12 +//
13 +// Run the build script first to produce the framework:
14 +// cd onde && .github/scripts/build-swift-xcframework.sh
15 +//
16 +// DISTRIBUTION
17 +//
18 +// The url + checksum below are updated automatically by CI on every release.
19 +// Do not edit them by hand — they are rewritten by build-swift-xcframework.yml
20 +// when a new onde GitHub Release is published.
21 +// ─────────────────────────────────────────────────────────────────────────────
22 +
23 let package = Package(
24 name: "Onde",
25 platforms: [
@@ -15,7 +33,9 @@ let package = Package(
33 targets: [
34 .binaryTarget(
35 name: "OndeFramework",
18 - path: "./../onde/sdk/Onde/OndeFramework.xcframework",
36 + url:
37 + "https://github.com/ondeinference/onde/releases/download/0.1.0/OndeFramework.xcframework.zip",
38 + checksum: "0000000000000000000000000000000000000000000000000000000000000000"
39 ),
40 .target(
41 name: "Onde",
README.md new
+137
@@ -0,0 +1,137 @@
1 +<p align="center">
2 + <img src="https://raw.githubusercontent.com/ondeinference/onde/main/assets/onde-inference-logo.svg" alt="Onde Inference" width="96">
3 +</p>
4 +
5 +<h1 align="center">Onde</h1>
6 +
7 +<p align="center">
8 + <strong>On-device LLM inference for Swift — optimized for <a href="https://en.wikipedia.org/wiki/Apple_silicon">Apple silicon</a>.</strong>
9 +</p>
10 +
11 +<p align="center">
12 + <a href="https://swiftpackageindex.com/ondeinference/onde-swift"><img src="https://img.shields.io/badge/Swift%20Package%20Index-onde--swift-235843?style=flat-square&labelColor=17211D" alt="Swift Package Index"></a>
13 + <a href="https://ondeinference.com"><img src="https://img.shields.io/badge/ondeinference.com-235843?style=flat-square&labelColor=17211D" alt="Website"></a>
14 + <a href="https://apps.apple.com/se/developer/splitfire-ab/id1831430993"><img src="https://img.shields.io/badge/App%20Store-live-235843?style=flat-square&labelColor=17211D" alt="App Store"></a>
15 +</p>
16 +
17 +---
18 +
19 +## Installation
20 +
21 +In Xcode: **File → Add Package Dependencies** and enter:
22 +
23 +```
24 +https://github.com/ondeinference/onde-swift
25 +```
26 +
27 +Or add it to your `Package.swift`:
28 +
29 +```swift
30 +dependencies: [
31 + .package(url: "https://github.com/ondeinference/onde-swift", from: "0.1.0")
32 +],
33 +targets: [
34 + .target(name: "MyApp", dependencies: [
35 + .product(name: "Onde", package: "onde-swift")
36 + ])
37 +]
38 +```
39 +
40 +## Platforms
41 +
42 +| Platform | Minimum | GPU Backend |
43 +|----------|---------|-------------|
44 +| iOS | 15.0 | Metal |
45 +| macOS | 11.0 | Metal |
46 +| tvOS | 15.0 | Metal |
47 +
48 +## Quick Start
49 +
50 +```swift
51 +import Onde
52 +
53 +let engine = OndeChatEngine()
54 +
55 +// Load the platform-appropriate default model:
56 +// iOS / tvOS → Qwen 2.5 1.5B (~941 MB)
57 +// macOS → Qwen 2.5 3B (~1.93 GB)
58 +let elapsed = try await engine.loadDefaultModel(
59 + systemPrompt: "You are a helpful assistant.",
60 + sampling: nil
61 +)
62 +
63 +let result = try await engine.sendMessage(message: "Hello!")
64 +print(result.text)
65 +```
66 +
67 +## Streaming
68 +
69 +```swift
70 +import Onde
71 +
72 +class StreamHandler: StreamChunkListener {
73 + func onChunk(chunk: StreamChunk) -> Bool {
74 + print(chunk.delta, terminator: "")
75 + return !chunk.done
76 + }
77 +}
78 +
79 +try await streamChatMessage(
80 + engine: engine,
81 + message: "Tell me a story.",
82 + listener: StreamHandler()
83 +)
84 +```
85 +
86 +## One-Shot Generation
87 +
88 +Run inference without modifying conversation history:
89 +
90 +```swift
91 +let result = try await engine.generate(
92 + messages: [userMessage(content: "Expand: a cat in space")],
93 + sampling: deterministicSamplingConfig()
94 +)
95 +```
96 +
97 +## Sandboxed App Setup
98 +
99 +On iOS and App Store macOS, configure the HuggingFace cache directory before any inference call:
100 +
101 +```swift
102 +import Foundation
103 +
104 +func setupInferenceEnvironment() {
105 + let appSupport = FileManager.default
106 + .urls(for: .applicationSupportDirectory, in: .userDomainMask)[0]
107 +
108 + let hfHome = appSupport.appendingPathComponent("huggingface")
109 + let hfHub = hfHome.appendingPathComponent("hub")
110 + try? FileManager.default.createDirectory(at: hfHub, withIntermediateDirectories: true)
111 +
112 + setenv("HF_HOME", hfHome.path, 1)
113 + setenv("HF_HUB_CACHE", hfHub.path, 1)
114 +
115 + let tmp = appSupport.appendingPathComponent("tmp")
116 + try? FileManager.default.createDirectory(at: tmp, withIntermediateDirectories: true)
117 + setenv("TMPDIR", tmp.path, 1)
118 +}
119 +```
120 +
121 +Call this once at app launch, before creating an `OndeChatEngine`.
122 +
123 +## Documentation
124 +
125 +- [Swift API Reference](https://ondeinference.com/docs/swift-package)
126 +- [Developer Guide](https://ondeinference.com/docs/dev)
127 +- [Rust Crate (onde)](https://github.com/ondeinference/onde)
128 +
129 +## License
130 +
131 +[MIT](LICENSE)
132 +
133 +---
134 +
135 +<p align="center">
136 + <sub>© 2026 <a href="https://ondeinference.com">Onde Inference</a></sub>
137 +</p>
\ No newline at end of file