Skip to content

Commit 9dea1d1

Browse files
Release v0.19.5: Fix App Store validation by using library-format xcframeworks
- Restructure xcframeworks from .framework format to plain .a library format to prevent SPM/Xcode from embedding static libraries as dynamic frameworks - Split onnxruntime into iOS (static) and macOS (dynamic) xcframeworks since xcframeworks can't mix library types - Make all library products explicitly .static in Package.swift - Add build phase to strip SPM-generated framework stubs from app bundle - Update build-ios.sh and create-onnxruntime-xcframework.sh to produce library-format xcframeworks going forward This fixes: "Invalid Bundle - does not support minimum OS Version" and "Upload Symbols Failed" errors during App Store validation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 1baf03b commit 9dea1d1

7 files changed

Lines changed: 205 additions & 130 deletions

File tree

Package.swift

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ 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.4"
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,6 +74,7 @@ let package = Package(
7174
// =================================================================
7275
.library(
7376
name: "RunAnywhereLlamaCPP",
77+
type: .static,
7478
targets: ["LlamaCPPRuntime"]
7579
),
7680

@@ -79,6 +83,7 @@ let package = Package(
7983
// =================================================================
8084
.library(
8185
name: "RunAnywhereWhisperKit",
86+
type: .static,
8287
targets: ["WhisperKitRuntime"]
8388
),
8489
],
@@ -121,7 +126,11 @@ let package = Package(
121126
// =================================================================
122127
.target(
123128
name: "ONNXBackend",
124-
dependencies: ["RABackendONNXBinary", "ONNXRuntimeBinary"],
129+
dependencies: [
130+
"RABackendONNXBinary",
131+
.target(name: "ONNXRuntimeiOSBinary", condition: .when(platforms: [.iOS])),
132+
.target(name: "ONNXRuntimemacOSBinary", condition: .when(platforms: [.macOS])),
133+
],
125134
path: "sdk/runanywhere-swift/Sources/ONNXRuntime/include",
126135
publicHeadersPath: "."
127136
),
@@ -248,14 +257,19 @@ func binaryTargets() -> [Target] {
248257
),
249258
]
250259

251-
// Local combined ONNX Runtime xcframework (iOS + macOS)
252-
// Created by: cd sdk/runanywhere-swift && ./scripts/create-onnxruntime-xcframework.sh
253-
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+
),
254268
.binaryTarget(
255-
name: "ONNXRuntimeBinary",
256-
path: "sdk/runanywhere-swift/Binaries/onnxruntime.xcframework"
257-
)
258-
)
269+
name: "ONNXRuntimemacOSBinary",
270+
path: "sdk/runanywhere-swift/Binaries/onnxruntime-macos.xcframework"
271+
),
272+
])
259273

260274
return targets
261275
} else {
@@ -268,22 +282,27 @@ func binaryTargets() -> [Target] {
268282
.binaryTarget(
269283
name: "RACommonsBinary",
270284
url: "https://github.com/RunanywhereAI/runanywhere-sdks/releases/download/v\(sdkVersion)/RACommons-v\(sdkVersion).zip",
271-
checksum: "31c071d35904d2de76981d8b10588373e421ace483def7161495847f0e9bb244"
285+
checksum: "93372c680f04fc02088044e4f2efc8c93e906a2a8a4983d8b2d8832a22d59c01"
272286
),
273287
.binaryTarget(
274288
name: "RABackendLlamaCPPBinary",
275289
url: "https://github.com/RunanywhereAI/runanywhere-sdks/releases/download/v\(sdkVersion)/RABackendLLAMACPP-v\(sdkVersion).zip",
276-
checksum: "c29a7013a59b10ff00fe8170563ec3d5a0c4dea7b22ddc0efb87ae332793cc73"
290+
checksum: "f189fc03bc86bf4839ae743e857a09563633ca9fb3f449cc30e82fbec70840fe"
277291
),
278292
.binaryTarget(
279293
name: "RABackendONNXBinary",
280294
url: "https://github.com/RunanywhereAI/runanywhere-sdks/releases/download/v\(sdkVersion)/RABackendONNX-v\(sdkVersion).zip",
281-
checksum: "2d77027c7a0b62366dd4c8d0420c24dc29f44f5a55e4e81cd78066026649b4f2"
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"
282301
),
283302
.binaryTarget(
284-
name: "ONNXRuntimeBinary",
285-
url: "https://github.com/RunanywhereAI/runanywhere-sdks/releases/download/v\(sdkVersion)/onnxruntime-v\(sdkVersion).zip",
286-
checksum: "35ed4f213ccd6d8472ded74dbccb8f6a6614977584604b042563761f20613fe7"
303+
name: "ONNXRuntimemacOSBinary",
304+
url: "https://github.com/RunanywhereAI/runanywhere-sdks/releases/download/v\(sdkVersion)/onnxruntime-macos-v\(sdkVersion).zip",
305+
checksum: "f73db9dc09012325b35fd3da74de794a75f4e9971d9b923af0805d6ab1dfc243"
287306
),
288307
]
289308
}

Playground/YapRun/YapRun.xcodeproj/project.pbxproj

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
5425BDB02F4C148700633DA2 /* RunAnywhere in Frameworks */ = {isa = PBXBuildFile; productRef = 5425BDAF2F4C148700633DA2 /* RunAnywhere */; };
11+
5425BDB22F4C148700633DA2 /* RunAnywhereONNX in Frameworks */ = {isa = PBXBuildFile; productRef = 5425BDB12F4C148700633DA2 /* RunAnywhereONNX */; };
12+
5425BDB42F4C148700633DA2 /* RunAnywhereWhisperKit in Frameworks */ = {isa = PBXBuildFile; productRef = 5425BDB32F4C148700633DA2 /* RunAnywhereWhisperKit */; };
1013
54398FEF2F497A03009D6B51 /* YapRunKeyboard.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 54398FE82F497A02009D6B51 /* YapRunKeyboard.appex */; platformFilter = ios; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
1114
54398FFC2F497A34009D6B51 /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 54398FFB2F497A34009D6B51 /* WidgetKit.framework */; };
1215
54398FFE2F497A34009D6B51 /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 54398FFD2F497A34009D6B51 /* SwiftUI.framework */; };
1316
5439900B2F497A35009D6B51 /* YapRunActivityExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 54398FF92F497A34009D6B51 /* YapRunActivityExtension.appex */; platformFilter = ios; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
14-
54F2BC172F4BDEC500D2FB5A /* RunAnywhere in Frameworks */ = {isa = PBXBuildFile; productRef = 54F2BC162F4BDEC500D2FB5A /* RunAnywhere */; };
15-
54F2BC192F4BDEC500D2FB5A /* RunAnywhereONNX in Frameworks */ = {isa = PBXBuildFile; productRef = 54F2BC182F4BDEC500D2FB5A /* RunAnywhereONNX */; };
16-
54F2BC1B2F4BDEC500D2FB5A /* RunAnywhereWhisperKit in Frameworks */ = {isa = PBXBuildFile; productRef = 54F2BC1A2F4BDEC500D2FB5A /* RunAnywhereWhisperKit */; };
1717
/* End PBXBuildFile section */
1818

1919
/* Begin PBXContainerItemProxy section */
@@ -62,6 +62,23 @@
6262
};
6363
/* End PBXCopyFilesBuildPhase section */
6464

65+
/* Begin PBXShellScriptBuildPhase section */
66+
AA000001STRIPSTATICFWS /* Strip Static Frameworks */ = {
67+
isa = PBXShellScriptBuildPhase;
68+
buildActionMask = 2147483647;
69+
files = (
70+
);
71+
inputPaths = (
72+
);
73+
name = "Strip Static Frameworks";
74+
outputPaths = (
75+
);
76+
runOnlyForDeploymentPostprocessing = 0;
77+
shellPath = /bin/sh;
78+
shellScript = "# Remove SPM-generated framework stubs for our static libraries.\n# These are statically linked into the app binary (verified: no @rpath references).\n# SPM creates these empty dynamic framework wrappers but they are not needed\n# and cause App Store validation failures.\nFRAMEWORKS_TO_STRIP=\"RACommons RABackendONNX RABackendLLAMACPP onnxruntime\"\nfor FW_DIR in \"${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}\" \"${CODESIGNING_FOLDER_PATH}/Frameworks\" \"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}\"; do\n if [ -d \"${FW_DIR}\" ]; then\n for fw in $FRAMEWORKS_TO_STRIP; do\n if [ -d \"${FW_DIR}/${fw}.framework\" ]; then\n echo \"Removing unnecessary framework stub: ${fw}.framework\"\n rm -rf \"${FW_DIR}/${fw}.framework\"\n fi\n done\n fi\ndone\n";
79+
};
80+
/* End PBXShellScriptBuildPhase section */
81+
6582
/* Begin PBXFileReference section */
6683
54398FBA2F4979D2009D6B51 /* YapRun.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = YapRun.app; sourceTree = BUILT_PRODUCTS_DIR; };
6784
54398FC72F4979D3009D6B51 /* YapRunTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = YapRunTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -139,9 +156,9 @@
139156
isa = PBXFrameworksBuildPhase;
140157
buildActionMask = 2147483647;
141158
files = (
142-
54F2BC1B2F4BDEC500D2FB5A /* RunAnywhereWhisperKit in Frameworks */,
143-
54F2BC192F4BDEC500D2FB5A /* RunAnywhereONNX in Frameworks */,
144-
54F2BC172F4BDEC500D2FB5A /* RunAnywhere in Frameworks */,
159+
5425BDB42F4C148700633DA2 /* RunAnywhereWhisperKit in Frameworks */,
160+
5425BDB22F4C148700633DA2 /* RunAnywhereONNX in Frameworks */,
161+
5425BDB02F4C148700633DA2 /* RunAnywhere in Frameworks */,
145162
);
146163
runOnlyForDeploymentPostprocessing = 0;
147164
};
@@ -224,6 +241,7 @@
224241
54398FB72F4979D2009D6B51 /* Frameworks */,
225242
54398FB82F4979D2009D6B51 /* Resources */,
226243
54398FF42F497A03009D6B51 /* Embed Foundation Extensions */,
244+
AA000001STRIPSTATICFWS /* Strip Static Frameworks */,
227245
);
228246
buildRules = (
229247
);
@@ -236,9 +254,9 @@
236254
);
237255
name = YapRun;
238256
packageProductDependencies = (
239-
54F2BC162F4BDEC500D2FB5A /* RunAnywhere */,
240-
54F2BC182F4BDEC500D2FB5A /* RunAnywhereONNX */,
241-
54F2BC1A2F4BDEC500D2FB5A /* RunAnywhereWhisperKit */,
257+
5425BDAF2F4C148700633DA2 /* RunAnywhere */,
258+
5425BDB12F4C148700633DA2 /* RunAnywhereONNX */,
259+
5425BDB32F4C148700633DA2 /* RunAnywhereWhisperKit */,
242260
);
243261
productName = YapRun;
244262
productReference = 54398FBA2F4979D2009D6B51 /* YapRun.app */;
@@ -373,7 +391,7 @@
373391
mainGroup = 54398FB12F4979D2009D6B51;
374392
minimizedProjectReferenceProxies = 1;
375393
packageReferences = (
376-
54F2BC152F4BDEC500D2FB5A /* XCRemoteSwiftPackageReference "runanywhere-sdks" */,
394+
5425BDAE2F4C148700633DA2 /* XCRemoteSwiftPackageReference "runanywhere-sdks" */,
377395
);
378396
preferredProjectObjectVersion = 77;
379397
productRefGroup = 54398FBB2F4979D2009D6B51 /* Products */;
@@ -529,7 +547,7 @@
529547
DEVELOPMENT_TEAM = L86FH3K93L;
530548
ENABLE_STRICT_OBJC_MSGSEND = YES;
531549
ENABLE_TESTABILITY = YES;
532-
ENABLE_USER_SCRIPT_SANDBOXING = YES;
550+
ENABLE_USER_SCRIPT_SANDBOXING = NO;
533551
GCC_C_LANGUAGE_STANDARD = gnu17;
534552
GCC_DYNAMIC_NO_PIC = NO;
535553
GCC_NO_COMMON_BLOCKS = YES;
@@ -591,7 +609,7 @@
591609
DEVELOPMENT_TEAM = L86FH3K93L;
592610
ENABLE_NS_ASSERTIONS = NO;
593611
ENABLE_STRICT_OBJC_MSGSEND = YES;
594-
ENABLE_USER_SCRIPT_SANDBOXING = YES;
612+
ENABLE_USER_SCRIPT_SANDBOXING = NO;
595613
GCC_C_LANGUAGE_STANDARD = gnu17;
596614
GCC_NO_COMMON_BLOCKS = YES;
597615
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
@@ -993,30 +1011,30 @@
9931011
/* End XCConfigurationList section */
9941012

9951013
/* Begin XCRemoteSwiftPackageReference section */
996-
54F2BC152F4BDEC500D2FB5A /* XCRemoteSwiftPackageReference "runanywhere-sdks" */ = {
1014+
5425BDAE2F4C148700633DA2 /* XCRemoteSwiftPackageReference "runanywhere-sdks" */ = {
9971015
isa = XCRemoteSwiftPackageReference;
9981016
repositoryURL = "https://github.com/RunanywhereAI/runanywhere-sdks";
9991017
requirement = {
10001018
kind = upToNextMajorVersion;
1001-
minimumVersion = 0.19.3;
1019+
minimumVersion = 0.19.4;
10021020
};
10031021
};
10041022
/* End XCRemoteSwiftPackageReference section */
10051023

10061024
/* Begin XCSwiftPackageProductDependency section */
1007-
54F2BC162F4BDEC500D2FB5A /* RunAnywhere */ = {
1025+
5425BDAF2F4C148700633DA2 /* RunAnywhere */ = {
10081026
isa = XCSwiftPackageProductDependency;
1009-
package = 54F2BC152F4BDEC500D2FB5A /* XCRemoteSwiftPackageReference "runanywhere-sdks" */;
1027+
package = 5425BDAE2F4C148700633DA2 /* XCRemoteSwiftPackageReference "runanywhere-sdks" */;
10101028
productName = RunAnywhere;
10111029
};
1012-
54F2BC182F4BDEC500D2FB5A /* RunAnywhereONNX */ = {
1030+
5425BDB12F4C148700633DA2 /* RunAnywhereONNX */ = {
10131031
isa = XCSwiftPackageProductDependency;
1014-
package = 54F2BC152F4BDEC500D2FB5A /* XCRemoteSwiftPackageReference "runanywhere-sdks" */;
1032+
package = 5425BDAE2F4C148700633DA2 /* XCRemoteSwiftPackageReference "runanywhere-sdks" */;
10151033
productName = RunAnywhereONNX;
10161034
};
1017-
54F2BC1A2F4BDEC500D2FB5A /* RunAnywhereWhisperKit */ = {
1035+
5425BDB32F4C148700633DA2 /* RunAnywhereWhisperKit */ = {
10181036
isa = XCSwiftPackageProductDependency;
1019-
package = 54F2BC152F4BDEC500D2FB5A /* XCRemoteSwiftPackageReference "runanywhere-sdks" */;
1037+
package = 5425BDAE2F4C148700633DA2 /* XCRemoteSwiftPackageReference "runanywhere-sdks" */;
10201038
productName = RunAnywhereWhisperKit;
10211039
};
10221040
/* End XCSwiftPackageProductDependency section */

Playground/YapRun/YapRun.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

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

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

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -427,18 +427,26 @@ EOF
427427
"${BUILD_DIR}/SIMULATOR/${FRAMEWORK_NAME}.framework/${FRAMEWORK_NAME}" \
428428
-output "${SIM_FAT}/${FRAMEWORK_NAME}.framework/${FRAMEWORK_NAME}"
429429

430-
# Create XCFramework (iOS + optionally macOS)
430+
# Create XCFramework using library format (prevents SPM from embedding static libs)
431431
local XCFW_PATH="${DIST_DIR}/${FRAMEWORK_NAME}.xcframework"
432432
rm -rf "${XCFW_PATH}"
433433

434+
# Prepare library files (rename binary to lib*.a for library format)
435+
local IOS_LIB="${BUILD_DIR}/OS/lib${FRAMEWORK_NAME}.a"
436+
cp "${BUILD_DIR}/OS/${FRAMEWORK_NAME}.framework/${FRAMEWORK_NAME}" "${IOS_LIB}"
437+
438+
local SIM_LIB="${SIM_FAT}/lib${FRAMEWORK_NAME}.a"
439+
cp "${SIM_FAT}/${FRAMEWORK_NAME}.framework/${FRAMEWORK_NAME}" "${SIM_LIB}"
440+
434441
local XCFW_ARGS=(
435-
-framework "${BUILD_DIR}/OS/${FRAMEWORK_NAME}.framework"
436-
-framework "${SIM_FAT}/${FRAMEWORK_NAME}.framework"
442+
-library "${IOS_LIB}" -headers "${BUILD_DIR}/OS/${FRAMEWORK_NAME}.framework/Headers"
443+
-library "${SIM_LIB}" -headers "${SIM_FAT}/${FRAMEWORK_NAME}.framework/Headers"
437444
)
438445

439446
if [[ "$INCLUDE_MACOS" == true && -f "${BUILD_DIR}/MACOS/${FRAMEWORK_NAME}.framework/${FRAMEWORK_NAME}" ]]; then
440-
create_macos_versioned_framework "${BUILD_DIR}/MACOS" "${FRAMEWORK_NAME}"
441-
XCFW_ARGS+=(-framework "${BUILD_DIR}/MACOS/${FRAMEWORK_NAME}.framework")
447+
local MACOS_LIB="${BUILD_DIR}/MACOS/lib${FRAMEWORK_NAME}.a"
448+
cp "${BUILD_DIR}/MACOS/${FRAMEWORK_NAME}.framework/${FRAMEWORK_NAME}" "${MACOS_LIB}"
449+
XCFW_ARGS+=(-library "${MACOS_LIB}" -headers "${BUILD_DIR}/MACOS/${FRAMEWORK_NAME}.framework/Headers")
442450
log_info "Including macOS slice in ${FRAMEWORK_NAME}.xcframework"
443451
fi
444452

@@ -610,19 +618,27 @@ EOF
610618
"${BUILD_DIR}/SIMULATOR/${FRAMEWORK_NAME}.framework/${FRAMEWORK_NAME}" \
611619
-output "${SIM_FAT}/${FRAMEWORK_NAME}.framework/${FRAMEWORK_NAME}" 2>/dev/null || true
612620

613-
# Create XCFramework (iOS + optionally macOS)
621+
# Create XCFramework using library format (prevents SPM from embedding static libs)
614622
local XCFW_PATH="${DIST_DIR}/${FRAMEWORK_NAME}.xcframework"
615623
rm -rf "${XCFW_PATH}"
616624

617625
if [[ -f "${BUILD_DIR}/OS/${FRAMEWORK_NAME}.framework/${FRAMEWORK_NAME}" ]]; then
626+
# Prepare library files (rename binary to lib*.a for library format)
627+
local IOS_LIB="${BUILD_DIR}/OS/lib${FRAMEWORK_NAME}.a"
628+
cp "${BUILD_DIR}/OS/${FRAMEWORK_NAME}.framework/${FRAMEWORK_NAME}" "${IOS_LIB}"
629+
630+
local SIM_LIB="${SIM_FAT}/lib${FRAMEWORK_NAME}.a"
631+
cp "${SIM_FAT}/${FRAMEWORK_NAME}.framework/${FRAMEWORK_NAME}" "${SIM_LIB}"
632+
618633
local XCFW_ARGS=(
619-
-framework "${BUILD_DIR}/OS/${FRAMEWORK_NAME}.framework"
620-
-framework "${SIM_FAT}/${FRAMEWORK_NAME}.framework"
634+
-library "${IOS_LIB}" -headers "${BUILD_DIR}/OS/${FRAMEWORK_NAME}.framework/Headers"
635+
-library "${SIM_LIB}" -headers "${SIM_FAT}/${FRAMEWORK_NAME}.framework/Headers"
621636
)
622637

623638
if [[ "$INCLUDE_MACOS" == true && -f "${BUILD_DIR}/MACOS/${FRAMEWORK_NAME}.framework/${FRAMEWORK_NAME}" ]]; then
624-
create_macos_versioned_framework "${BUILD_DIR}/MACOS" "${FRAMEWORK_NAME}"
625-
XCFW_ARGS+=(-framework "${BUILD_DIR}/MACOS/${FRAMEWORK_NAME}.framework")
639+
local MACOS_LIB="${BUILD_DIR}/MACOS/lib${FRAMEWORK_NAME}.a"
640+
cp "${BUILD_DIR}/MACOS/${FRAMEWORK_NAME}.framework/${FRAMEWORK_NAME}" "${MACOS_LIB}"
641+
XCFW_ARGS+=(-library "${MACOS_LIB}" -headers "${BUILD_DIR}/MACOS/${FRAMEWORK_NAME}.framework/Headers")
626642
log_info "Including macOS slice in ${FRAMEWORK_NAME}.xcframework"
627643
fi
628644

sdk/runanywhere-swift/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.19.4
1+
0.19.5

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

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -258,24 +258,42 @@ install_frameworks() {
258258
fi
259259
done
260260

261-
# Install ONNX Runtime xcframework
261+
# Install ONNX Runtime xcframeworks (split: iOS static library + macOS dynamic framework)
262+
# Remove old combined xcframework if present
263+
rm -rf "$BINARIES_DIR/onnxruntime.xcframework"
264+
262265
if [[ "$INCLUDE_MACOS" == true ]]; then
263-
# macOS included: create combined iOS + macOS xcframework
266+
# macOS included: create split iOS + macOS xcframeworks
264267
local ONNX_SCRIPT="$SWIFT_SDK_DIR/scripts/create-onnxruntime-xcframework.sh"
265268
if [[ -x "$ONNX_SCRIPT" ]]; then
266-
log_step "Creating combined ONNX Runtime xcframework (iOS + macOS)..."
269+
log_step "Creating split ONNX Runtime xcframeworks (iOS + macOS)..."
267270
"$ONNX_SCRIPT"
268271
else
269-
log_warn "create-onnxruntime-xcframework.sh not found, skipping combined ONNX Runtime"
272+
log_warn "create-onnxruntime-xcframework.sh not found, skipping ONNX Runtime"
270273
fi
271274
else
272-
# iOS only: copy the pre-built iOS onnxruntime xcframework directly
275+
# iOS only: create library-format xcframework from pre-built iOS onnxruntime
273276
local ONNX_SRC="$COMMONS_DIR/third_party/onnxruntime-ios/onnxruntime.xcframework"
274277
if [[ -d "$ONNX_SRC" ]]; then
275-
log_step "Copying onnxruntime.xcframework (iOS only)"
276-
rm -rf "$BINARIES_DIR/onnxruntime.xcframework"
277-
cp -r "$ONNX_SRC" "$BINARIES_DIR/"
278-
log_info " onnxruntime.xcframework ($(du -sh "$ONNX_SRC" | cut -f1))"
278+
log_step "Creating onnxruntime-ios.xcframework (library format)"
279+
local ONNX_TEMP=$(mktemp -d)
280+
local XCFW_ARGS=()
281+
for SLICE_DIR in "${ONNX_SRC}"/*/; do
282+
local SLICE_NAME=$(basename "$SLICE_DIR")
283+
[[ "$SLICE_NAME" == "Info.plist" ]] && continue
284+
local DEST="${ONNX_TEMP}/${SLICE_NAME}"
285+
mkdir -p "$DEST"
286+
if [[ -d "${SLICE_DIR}/onnxruntime.framework" ]]; then
287+
cp "${SLICE_DIR}/onnxruntime.framework/onnxruntime" "${DEST}/libonnxruntime.a"
288+
cp -R "${SLICE_DIR}/onnxruntime.framework/Headers" "${DEST}/Headers" 2>/dev/null || true
289+
fi
290+
XCFW_ARGS+=(-library "${DEST}/libonnxruntime.a")
291+
[[ -d "${DEST}/Headers" ]] && XCFW_ARGS+=(-headers "${DEST}/Headers")
292+
done
293+
rm -rf "$BINARIES_DIR/onnxruntime-ios.xcframework"
294+
xcodebuild -create-xcframework "${XCFW_ARGS[@]}" -output "$BINARIES_DIR/onnxruntime-ios.xcframework"
295+
rm -rf "$ONNX_TEMP"
296+
log_info " onnxruntime-ios.xcframework created"
279297
else
280298
log_warn "onnxruntime.xcframework not found at $ONNX_SRC"
281299
fi

0 commit comments

Comments
 (0)