Skip to content

Commit 2b4699a

Browse files
Merge pull request #409 from RunanywhereAI/smonga/whisperKitIntegration
[Swift-SDK] [Swift-Example] Whisper kit integration
2 parents 87fcb95 + 4e0ebc1 commit 2b4699a

56 files changed

Lines changed: 2543 additions & 413 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,3 +383,4 @@ sdk/runanywhere-react-native/packages/*/ios/xcframeworks/
383383
# Node
384384
node_modules/
385385
/tools/
386+
*.trace

Package.resolved

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 61 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ import Foundation
3737
// ./scripts/build-swift.sh --set-remote (sets useLocalBinaries = false)
3838
//
3939
// =============================================================================
40-
let useLocalBinaries = true // Toggle: true for local dev, false for release
40+
let useLocalBinaries = false // Toggle: true for local dev, false for release
4141

4242
// Version for remote XCFrameworks (used when testLocal = false)
4343
// Updated automatically by CI/CD during releases
44-
let sdkVersion = "0.19.1"
44+
let sdkVersion = "0.19.5"
4545

4646
let package = Package(
4747
name: "runanywhere-sdks",
@@ -52,9 +52,11 @@ let package = Package(
5252
products: [
5353
// =================================================================
5454
// Core SDK - always needed
55+
// Static to prevent SPM from embedding binary target stubs as dynamic frameworks
5556
// =================================================================
5657
.library(
5758
name: "RunAnywhere",
59+
type: .static,
5860
targets: ["RunAnywhere"]
5961
),
6062

@@ -63,6 +65,7 @@ let package = Package(
6365
// =================================================================
6466
.library(
6567
name: "RunAnywhereONNX",
68+
type: .static,
6669
targets: ["ONNXRuntime"]
6770
),
6871

@@ -71,8 +74,18 @@ let package = Package(
7174
// =================================================================
7275
.library(
7376
name: "RunAnywhereLlamaCPP",
77+
type: .static,
7478
targets: ["LlamaCPPRuntime"]
7579
),
80+
81+
// =================================================================
82+
// WhisperKit Backend - adds STT via Apple Neural Engine
83+
// =================================================================
84+
.library(
85+
name: "RunAnywhereWhisperKit",
86+
type: .static,
87+
targets: ["WhisperKitRuntime"]
88+
),
7689
],
7790
dependencies: [
7891
.package(url: "https://github.com/apple/swift-crypto.git", from: "3.0.0"),
@@ -84,6 +97,8 @@ let package = Package(
8497
.package(url: "https://github.com/getsentry/sentry-cocoa", from: "8.40.0"),
8598
// ml-stable-diffusion for CoreML-based image generation
8699
.package(url: "https://github.com/apple/ml-stable-diffusion.git", from: "1.1.0"),
100+
// WhisperKit for Neural Engine STT
101+
.package(url: "https://github.com/argmaxinc/WhisperKit.git", from: "0.9.0"),
87102
],
88103
targets: [
89104
// =================================================================
@@ -111,7 +126,11 @@ let package = Package(
111126
// =================================================================
112127
.target(
113128
name: "ONNXBackend",
114-
dependencies: ["RABackendONNXBinary", "ONNXRuntimeBinary"],
129+
dependencies: [
130+
"RABackendONNXBinary",
131+
.target(name: "ONNXRuntimeiOSBinary", condition: .when(platforms: [.iOS])),
132+
.target(name: "ONNXRuntimemacOSBinary", condition: .when(platforms: [.macOS])),
133+
],
115134
path: "sdk/runanywhere-swift/Sources/ONNXRuntime/include",
116135
publicHeadersPath: "."
117136
),
@@ -181,6 +200,22 @@ let package = Package(
181200
]
182201
),
183202

203+
// =================================================================
204+
// WhisperKit Runtime Backend (Apple Neural Engine STT)
205+
// =================================================================
206+
.target(
207+
name: "WhisperKitRuntime",
208+
dependencies: [
209+
"RunAnywhere",
210+
.product(name: "WhisperKit", package: "whisperkit"),
211+
],
212+
path: "sdk/runanywhere-swift/Sources/WhisperKitRuntime",
213+
linkerSettings: [
214+
.linkedFramework("CoreML"),
215+
.linkedFramework("Accelerate"),
216+
]
217+
),
218+
184219
// =================================================================
185220
// RunAnywhere unit tests (e.g. AudioCaptureManager – Issue #198)
186221
// =================================================================
@@ -222,14 +257,19 @@ func binaryTargets() -> [Target] {
222257
),
223258
]
224259

225-
// Local combined ONNX Runtime xcframework (iOS + macOS)
226-
// Created by: cd sdk/runanywhere-swift && ./scripts/create-onnxruntime-xcframework.sh
227-
targets.append(
260+
// ONNX Runtime xcframeworks - split by platform
261+
// iOS: static library format (not embedded in app bundle)
262+
// macOS: dynamic framework format (embedded in app bundle)
263+
targets.append(contentsOf: [
264+
.binaryTarget(
265+
name: "ONNXRuntimeiOSBinary",
266+
path: "sdk/runanywhere-swift/Binaries/onnxruntime-ios.xcframework"
267+
),
228268
.binaryTarget(
229-
name: "ONNXRuntimeBinary",
230-
path: "sdk/runanywhere-swift/Binaries/onnxruntime.xcframework"
231-
)
232-
)
269+
name: "ONNXRuntimemacOSBinary",
270+
path: "sdk/runanywhere-swift/Binaries/onnxruntime-macos.xcframework"
271+
),
272+
])
233273

234274
return targets
235275
} else {
@@ -242,22 +282,27 @@ func binaryTargets() -> [Target] {
242282
.binaryTarget(
243283
name: "RACommonsBinary",
244284
url: "https://github.com/RunanywhereAI/runanywhere-sdks/releases/download/v\(sdkVersion)/RACommons-v\(sdkVersion).zip",
245-
checksum: "f6bc152b1689d7549d6a7b5e692f6babb0efc44fe334c0e60acfc0c12d848c44"
285+
checksum: "93372c680f04fc02088044e4f2efc8c93e906a2a8a4983d8b2d8832a22d59c01"
246286
),
247287
.binaryTarget(
248288
name: "RABackendLlamaCPPBinary",
249289
url: "https://github.com/RunanywhereAI/runanywhere-sdks/releases/download/v\(sdkVersion)/RABackendLLAMACPP-v\(sdkVersion).zip",
250-
checksum: "ba150fd924f71c2137d6cad0a294c3f9c2da5bc748b547cced87bc0910a9b327"
290+
checksum: "f189fc03bc86bf4839ae743e857a09563633ca9fb3f449cc30e82fbec70840fe"
251291
),
252292
.binaryTarget(
253293
name: "RABackendONNXBinary",
254294
url: "https://github.com/RunanywhereAI/runanywhere-sdks/releases/download/v\(sdkVersion)/RABackendONNX-v\(sdkVersion).zip",
255-
checksum: "00b28c0542ab25585c534b4e33ddacd4a1d24447aa8c2178949aad89eb56cb1f"
295+
checksum: "a3571b5c46057c55d61eac471a97fc6e4c92bc714afe2002b96c346551950ef9"
296+
),
297+
.binaryTarget(
298+
name: "ONNXRuntimeiOSBinary",
299+
url: "https://github.com/RunanywhereAI/runanywhere-sdks/releases/download/v\(sdkVersion)/onnxruntime-ios-v\(sdkVersion).zip",
300+
checksum: "9dbb6cfc8f65a9ff3f7351d01afb592698a7c0681b9c0006abdceaaac800ee4b"
256301
),
257302
.binaryTarget(
258-
name: "ONNXRuntimeBinary",
259-
url: "https://github.com/RunanywhereAI/runanywhere-sdks/releases/download/v\(sdkVersion)/onnxruntime-v\(sdkVersion).zip",
260-
checksum: "e0180262bd1b10fcda95aaf9aac595af5e6819bd454312b6fc8ffc3828db239f"
303+
name: "ONNXRuntimemacOSBinary",
304+
url: "https://github.com/RunanywhereAI/runanywhere-sdks/releases/download/v\(sdkVersion)/onnxruntime-macos-v\(sdkVersion).zip",
305+
checksum: "f73db9dc09012325b35fd3da74de794a75f4e9971d9b923af0805d6ab1dfc243"
261306
),
262307
]
263308
}

0 commit comments

Comments
 (0)