Skip to content

Commit 28577d9

Browse files
fixing ios/swift - remvoing ragbackend - refactor
1 parent 96e3569 commit 28577d9

5 files changed

Lines changed: 39 additions & 34 deletions

File tree

Package.swift

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import Foundation
3737
// ./scripts/build-swift.sh --set-remote (sets useLocalBinaries = false)
3838
//
3939
// =============================================================================
40-
let useLocalBinaries = false // Toggle: true for local dev, false for release
40+
let useLocalBinaries = true // 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
@@ -146,7 +146,6 @@ let package = Package(
146146
.product(name: "StableDiffusion", package: "ml-stable-diffusion"),
147147
"CRACommons",
148148
"RACommonsBinary",
149-
"RABackendRAGBinary",
150149
],
151150
path: "sdk/runanywhere-swift/Sources/RunAnywhere",
152151
exclude: ["CRACommons"],
@@ -256,10 +255,6 @@ func binaryTargets() -> [Target] {
256255
name: "RABackendONNXBinary",
257256
path: "sdk/runanywhere-swift/Binaries/RABackendONNX.xcframework"
258257
),
259-
.binaryTarget(
260-
name: "RABackendRAGBinary",
261-
path: "sdk/runanywhere-swift/Binaries/RABackendRAG.xcframework"
262-
),
263258
]
264259

265260
// ONNX Runtime xcframeworks - split by platform
@@ -311,14 +306,6 @@ func binaryTargets() -> [Target] {
311306
),
312307
]
313308

314-
targets.append(
315-
.binaryTarget(
316-
name: "RABackendRAGBinary",
317-
url: "https://github.com/RunanywhereAI/runanywhere-sdks/releases/download/v\(sdkVersion)/RABackendRAG-v\(sdkVersion).zip",
318-
checksum: "0000000000000000000000000000000000000000000000000000000000000000" // TODO: Replace with actual checksum on release
319-
)
320-
)
321-
322309
return targets
323310
}
324311
}

examples/ios/RunAnywhereAI/RunAnywhereAI.xcodeproj/project.pbxproj

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
54398D332F4939A7009D6B51 /* RunAnywhereActivityExtensionExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 54398D202F4939A7009D6B51 /* RunAnywhereActivityExtensionExtension.appex */; platformFilters = (ios, ); settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
1515
58ABEDD22ED16DA40058D033 /* RunAnywhereONNX in Frameworks */ = {isa = PBXBuildFile; productRef = 58ABEDD12ED16DA40058D033 /* RunAnywhereONNX */; };
1616
58LLAMACPP12ED16DA40058D0 /* RunAnywhereLlamaCPP in Frameworks */ = {isa = PBXBuildFile; productRef = 58LLAMACPP02ED16DA40058D0 /* RunAnywhereLlamaCPP */; };
17-
58RAGBKND12ED16DA40058D03 /* RunAnywhereRAG in Frameworks */ = {isa = PBXBuildFile; productRef = 58RAGBKND02ED16DA40058D03 /* RunAnywhereRAG */; };
1817
58WHISPERKIT1ED16DA40058D0 /* RunAnywhereWhisperKit in Frameworks */ = {isa = PBXBuildFile; productRef = 58WHISPERKIT0ED16DA40058D0 /* RunAnywhereWhisperKit */; };
1918
RACACTIVITY01ACTIVITY01RAC /* DictationActivityAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = RACACTIVITY02ACTIVITY02RAC /* DictationActivityAttributes.swift */; };
2019
RACSHARED01RACSHARED01RACS /* SharedConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = RACSHARED02RACSHARED02RACS /* SharedConstants.swift */; };
@@ -169,7 +168,6 @@
169168
58ABEDD22ED16DA40058D033 /* RunAnywhereONNX in Frameworks */,
170169
541C59DA2E63772A00DD7839 /* RunAnywhere in Frameworks */,
171170
58LLAMACPP12ED16DA40058D0 /* RunAnywhereLlamaCPP in Frameworks */,
172-
58RAGBKND12ED16DA40058D03 /* RunAnywhereRAG in Frameworks */,
173171
58WHISPERKIT1ED16DA40058D0 /* RunAnywhereWhisperKit in Frameworks */,
174172
);
175173
runOnlyForDeploymentPostprocessing = 0;
@@ -310,7 +308,6 @@
310308
541C59D92E63772A00DD7839 /* RunAnywhere */,
311309
58ABEDD12ED16DA40058D033 /* RunAnywhereONNX */,
312310
58LLAMACPP02ED16DA40058D0 /* RunAnywhereLlamaCPP */,
313-
58RAGBKND02ED16DA40058D03 /* RunAnywhereRAG */,
314311
58WHISPERKIT0ED16DA40058D0 /* RunAnywhereWhisperKit */,
315312
);
316313
productName = RunAnywhereAI;
@@ -1082,11 +1079,6 @@
10821079
package = 58E021172E52A86000B722EF /* XCLocalSwiftPackageReference "../../.." */;
10831080
productName = RunAnywhereLlamaCPP;
10841081
};
1085-
58RAGBKND02ED16DA40058D03 /* RunAnywhereRAG */ = {
1086-
isa = XCSwiftPackageProductDependency;
1087-
package = 58E021172E52A86000B722EF /* XCLocalSwiftPackageReference "../../.." */;
1088-
productName = RunAnywhereRAG;
1089-
};
10901082
58WHISPERKIT0ED16DA40058D0 /* RunAnywhereWhisperKit */ = {
10911083
isa = XCSwiftPackageProductDependency;
10921084
package = 58E021172E52A86000B722EF /* XCLocalSwiftPackageReference "../../.." */;

sdk/runanywhere-commons/scripts/build-ios.sh

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@
2424
# --help Show this help
2525
#
2626
# OUTPUTS:
27-
# dist/RACommons.xcframework (always built)
27+
# dist/RACommons.xcframework (always built, includes RAG pipeline)
2828
# dist/RABackendLLAMACPP.xcframework (if --backend llamacpp or all)
2929
# dist/RABackendONNX.xcframework (if --backend onnx or all)
30-
# dist/RABackendRAG.xcframework (if --backend rag or all)
3130
#
3231
# EXAMPLES:
3332
# # Full build (all backends, iOS only)
@@ -730,21 +729,50 @@ main() {
730729
build_macos
731730
fi
732731

733-
# Step 3: Create RACommons.xcframework
732+
# Step 3: Merge RAG pipeline into rac_commons (RAG is a feature, not a separate backend)
733+
if [[ "$SKIP_BACKENDS" != true ]]; then
734+
log_step "Merging RAG pipeline into rac_commons..."
735+
local MERGE_PLATFORMS="OS SIMULATORARM64 SIMULATOR"
736+
if [[ "$INCLUDE_MACOS" == true ]]; then
737+
MERGE_PLATFORMS="$MERGE_PLATFORMS MACOS"
738+
fi
739+
for PLATFORM in $MERGE_PLATFORMS; do
740+
local PLATFORM_DIR="${BUILD_DIR}/${PLATFORM}"
741+
local COMMONS_LIB="${PLATFORM_DIR}/librac_commons.a"
742+
local RAG_LIB=""
743+
744+
for possible_path in \
745+
"${PLATFORM_DIR}/src/features/rag/librac_backend_rag.a" \
746+
"${PLATFORM_DIR}/src/backends/rag/librac_backend_rag.a" \
747+
"${PLATFORM_DIR}/librac_backend_rag.a"; do
748+
if [[ -f "$possible_path" ]]; then
749+
RAG_LIB="$possible_path"
750+
break
751+
fi
752+
done
753+
754+
if [[ -n "$RAG_LIB" && -f "$COMMONS_LIB" ]]; then
755+
libtool -static -o "${COMMONS_LIB}.merged" "$COMMONS_LIB" "$RAG_LIB"
756+
mv "${COMMONS_LIB}.merged" "$COMMONS_LIB"
757+
log_info " ${PLATFORM}: Merged librac_backend_rag.a into librac_commons.a"
758+
elif [[ -f "$COMMONS_LIB" ]]; then
759+
log_warn " ${PLATFORM}: librac_backend_rag.a not found — RAG not merged"
760+
fi
761+
done
762+
fi
763+
764+
# Step 4: Create RACommons.xcframework (now includes RAG pipeline)
734765
log_header "Creating XCFrameworks"
735766
create_xcframework "rac_commons" "RACommons"
736767

737-
# Step 4: Create backend XCFrameworks
768+
# Step 5: Create backend XCFrameworks
738769
if [[ "$SKIP_BACKENDS" != true ]]; then
739770
if [[ "$BUILD_BACKEND" == "all" || "$BUILD_BACKEND" == "llamacpp" ]]; then
740771
create_backend_xcframework "llamacpp" "RABackendLLAMACPP"
741772
fi
742773
if [[ "$BUILD_BACKEND" == "all" || "$BUILD_BACKEND" == "onnx" ]]; then
743774
create_backend_xcframework "onnx" "RABackendONNX"
744775
fi
745-
if [[ "$BUILD_BACKEND" == "all" || "$BUILD_BACKEND" == "rag" ]]; then
746-
create_backend_xcframework "rag" "RABackendRAG"
747-
fi
748776
fi
749777

750778
# Step 5: Package if requested
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// CRACommons shim — SPM requires at least one source file for C targets.
22
// All real implementations live in the xcframework binary targets:
3-
// - RACommons.xcframework (LoRA, Voice Agent, core)
4-
// - RABackendRAG.xcframework (RAG pipeline)
3+
// - RACommons.xcframework (LoRA, Voice Agent, RAG pipeline, core)
54
// - RABackendONNX.xcframework (STT/TTS/VAD)

sdk/runanywhere-swift/scripts/build-swift.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ install_frameworks() {
242242
mkdir -p "$BINARIES_DIR"
243243

244244
# All frameworks are now in dist/ (flat structure from build-ios.sh)
245-
for framework in RACommons RABackendLLAMACPP RABackendONNX RABackendRAG; do
245+
for framework in RACommons RABackendLLAMACPP RABackendONNX; do
246246
local src="$COMMONS_DIR/dist/${framework}.xcframework"
247247
if [[ -d "$src" ]]; then
248248
log_step "Copying ${framework}.xcframework"
@@ -405,8 +405,7 @@ main() {
405405
fi
406406
echo " 2. Build RACommons.xcframework"
407407
echo " 3. Build RABackendLLAMACPP.xcframework"
408-
echo " 4. Build RABackendONNX.xcframework"
409-
echo " 4b. Build RABackendRAG.xcframework"
408+
echo " 4. Build RABackendONNX.xcframework (RAG pipeline merged into RACommons)"
410409
if [[ "$INCLUDE_MACOS" == true ]]; then
411410
echo " (all xcframeworks will include macOS arm64 slices)"
412411
echo " 5. Create combined ONNX Runtime xcframework (iOS + macOS)"

0 commit comments

Comments
 (0)