@@ -43,6 +43,12 @@ let useLocalBinaries = true // Toggle: true for local dev, false for release
4343// Updated automatically by CI/CD during releases
4444let sdkVersion = " 0.19.1 "
4545
46+ // RAG binary is only available in local dev mode until the release artifact is published.
47+ // In remote mode, the RAG xcframework zip + checksum don't exist yet, so including the
48+ // binary target would block ALL SPM package resolution (not just RAG).
49+ // Set to true once RABackendRAG-v<version>.zip is published to GitHub releases.
50+ let ragRemoteBinaryAvailable = false
51+
4652let package = Package (
4753 name: " runanywhere-sdks " ,
4854 platforms: [
@@ -73,7 +79,8 @@ let package = Package(
7379 name: " RunAnywhereLlamaCPP " ,
7480 targets: [ " LlamaCPPRuntime " ]
7581 ) ,
76- ] ,
82+
83+ ] + ragProducts( ) ,
7784 dependencies: [
7885 . package ( url: " https://github.com/apple/swift-crypto.git " , from: " 3.0.0 " ) ,
7986 . package ( url: " https://github.com/Alamofire/Alamofire.git " , from: " 5.9.0 " ) ,
@@ -111,7 +118,7 @@ let package = Package(
111118 // =================================================================
112119 . target(
113120 name: " ONNXBackend " ,
114- dependencies: [ " RABackendONNXBinary " , " ONNXRuntimeBinary " ] ,
121+ dependencies: [ " RABackendONNXBinary " ] ,
115122 path: " sdk/runanywhere-swift/Sources/ONNXRuntime/include " ,
116123 publicHeadersPath: " . "
117124 ) ,
@@ -132,7 +139,7 @@ let package = Package(
132139 . product( name: " StableDiffusion " , package : " ml-stable-diffusion " ) ,
133140 " CRACommons " ,
134141 " RACommonsBinary " ,
135- ] ,
142+ ] + ragCoreDependencies ( ) ,
136143 path: " sdk/runanywhere-swift/Sources/RunAnywhere " ,
137144 exclude: [ " CRACommons " ] ,
138145 swiftSettings: [
@@ -194,9 +201,61 @@ let package = Package(
194201 path: " sdk/runanywhere-swift/Tests/RunAnywhereTests "
195202 ) ,
196203
197- ] + binaryTargets( )
204+ ] + ragTargets ( ) + binaryTargets( )
198205)
199206
207+ // =============================================================================
208+ // RAG TARGET HELPERS
209+ // =============================================================================
210+ // RAG targets are gated because the remote binary artifact doesn't exist yet.
211+ // Including a binary target with a placeholder checksum blocks ALL SPM resolution.
212+
213+ /// RAG product (library) — only included when the binary is available
214+ func ragProducts( ) -> [ Product ] {
215+ guard useLocalBinaries || ragRemoteBinaryAvailable else { return [ ] }
216+ return [
217+ . library(
218+ name: " RunAnywhereRAG " ,
219+ targets: [ " RAGRuntime " ]
220+ ) ,
221+ ]
222+ }
223+
224+ /// RAG dependency for the RunAnywhere core target
225+ func ragCoreDependencies( ) -> [ Target . Dependency ] {
226+ guard useLocalBinaries || ragRemoteBinaryAvailable else { return [ ] }
227+ return [
228+ " RAGBackend " ,
229+ ]
230+ }
231+
232+ /// RAG-related targets (C bridge + Swift runtime)
233+ func ragTargets( ) -> [ Target ] {
234+ guard useLocalBinaries || ragRemoteBinaryAvailable else { return [ ] }
235+ return [
236+ // C Bridge Module - RAG Backend Headers
237+ . target(
238+ name: " RAGBackend " ,
239+ dependencies: [ " RABackendRAGBinary " ] ,
240+ path: " sdk/runanywhere-swift/Sources/RAGRuntime/include " ,
241+ publicHeadersPath: " . "
242+ ) ,
243+ // RAG Runtime Backend
244+ . target(
245+ name: " RAGRuntime " ,
246+ dependencies: [
247+ " RunAnywhere " ,
248+ " RAGBackend " ,
249+ ] ,
250+ path: " sdk/runanywhere-swift/Sources/RAGRuntime " ,
251+ exclude: [ " include " ] ,
252+ linkerSettings: [
253+ . linkedLibrary( " c++ " ) ,
254+ ]
255+ ) ,
256+ ]
257+ }
258+
200259// =============================================================================
201260// BINARY TARGET SELECTION
202261// =============================================================================
@@ -224,16 +283,20 @@ func binaryTargets() -> [Target] {
224283 name: " RABackendONNXBinary " ,
225284 path: " sdk/runanywhere-swift/Binaries/RABackendONNX.xcframework "
226285 ) ,
286+ . binaryTarget(
287+ name: " RABackendRAGBinary " ,
288+ path: " sdk/runanywhere-swift/Binaries/RABackendRAG.xcframework "
289+ ) ,
227290 ]
228291
229292 // Local combined ONNX Runtime xcframework (iOS + macOS)
230293 // Created by: cd sdk/runanywhere-swift && ./scripts/create-onnxruntime-xcframework.sh
231- targets. append (
232- . binaryTarget(
233- name: " ONNXRuntimeBinary " ,
234- path: " sdk/runanywhere-swift/Binaries/onnxruntime.xcframework "
235- )
236- )
294+ // targets.append(
295+ // .binaryTarget(
296+ // name: "ONNXRuntimeBinary",
297+ // path: "sdk/runanywhere-swift/Binaries/onnxruntime.xcframework"
298+ // )
299+ // )
237300
238301 return targets
239302 } else {
@@ -242,7 +305,7 @@ func binaryTargets() -> [Target] {
242305 // Download XCFrameworks from GitHub releases
243306 // All xcframeworks include iOS + macOS slices (v0.19.0+)
244307 // =====================================================================
245- return [
308+ var targets : [ Target ] = [
246309 . binaryTarget(
247310 name: " RACommonsBinary " ,
248311 url: " https://github.com/RunanywhereAI/runanywhere-sdks/releases/download/v \( sdkVersion) /RACommons-v \( sdkVersion) .zip " ,
@@ -264,5 +327,18 @@ func binaryTargets() -> [Target] {
264327 checksum: " e0180262bd1b10fcda95aaf9aac595af5e6819bd454312b6fc8ffc3828db239f "
265328 ) ,
266329 ]
330+
331+ // Only include RAG binary when the release artifact is available
332+ if ragRemoteBinaryAvailable {
333+ targets. append (
334+ . binaryTarget(
335+ name: " RABackendRAGBinary " ,
336+ url: " https://github.com/RunanywhereAI/runanywhere-sdks/releases/download/v \( sdkVersion) /RABackendRAG-v \( sdkVersion) .zip " ,
337+ checksum: " 0000000000000000000000000000000000000000000000000000000000000000 " // Replace with actual checksum
338+ )
339+ )
340+ }
341+
342+ return targets
267343 }
268- }
344+ }
0 commit comments