Skip to content

Commit abd85c7

Browse files
committed
fix(swift): use binary target and versioned macOS framework for Xcode 26 compatibility
1 parent 07afe01 commit abd85c7

File tree

7 files changed

+62
-98
lines changed

7 files changed

+62
-98
lines changed

.github/workflows/main.yml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ jobs:
431431
codesign --sign "${{ secrets.APPLE_TEAM_ID }}" --timestamp --options runtime dist/ai.xcframework # Then sign the xcframework wrapper
432432
ditto -c -k --keepParent dist/ai.xcframework dist/ai.xcframework.zip
433433
xcrun notarytool submit dist/ai.xcframework.zip --apple-id "${{ secrets.APPLE_ID }}" --password "${{ secrets.APPLE_PASSWORD }}" --team-id "${{ secrets.APPLE_TEAM_ID }}" --wait
434-
rm dist/ai.xcframework.zip
434+
rm -rf dist/ai.xcframework
435435
436436
- name: cleanup keychain for codesign
437437
if: matrix.os == 'macos-15'
@@ -524,7 +524,11 @@ jobs:
524524
if [[ "$name" != "ai-apple-xcframework" && "$name" != "ai-android-aar" ]]; then
525525
tar -czf "${name}-${VERSION}.tar.gz" -C "$folder" .
526526
fi
527-
if [[ "$name" != "ai-android-aar" ]]; then
527+
if [[ "$name" == "ai-apple-xcframework" ]]; then
528+
# Use the ditto-created zip that preserves macOS symlinks and extract for other steps
529+
cp "$folder/ai.xcframework.zip" "${name}-${VERSION}.zip"
530+
unzip -q "$folder/ai.xcframework.zip" -d "$folder/"
531+
elif [[ "$name" != "ai-android-aar" ]]; then
528532
(cd "$folder" && zip -rq "../../${name}-${VERSION}.zip" .)
529533
else
530534
cp "$folder"/*.aar "${name}-${VERSION}.aar"
@@ -618,6 +622,23 @@ jobs:
618622
echo " Platform packages: 7"
619623
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
620624
625+
- name: update Package.swift checksum and version
626+
if: steps.tag.outputs.version != ''
627+
run: |
628+
VERSION=${{ steps.tag.outputs.version }}
629+
ZIP="ai-apple-xcframework-${VERSION}.zip"
630+
if [ -f "$ZIP" ]; then
631+
CHECKSUM=$(swift package compute-checksum "$ZIP")
632+
URL="https://github.com/sqliteai/sqlite-ai/releases/download/${VERSION}/${ZIP}"
633+
sed -i "s|url: \".*apple-xcframework.*\"|url: \"${URL}\"|" Package.swift
634+
sed -i "s|checksum: \".*\"|checksum: \"${CHECKSUM}\"|" Package.swift
635+
git config --global user.email "$GITHUB_ACTOR@users.noreply.github.com"
636+
git config --global user.name "$GITHUB_ACTOR"
637+
git add Package.swift
638+
git commit -m "Update Package.swift checksum for ${VERSION} [skip ci]" || true
639+
git push origin main || true
640+
fi
641+
621642
- uses: softprops/action-gh-release@v2.2.1
622643
if: steps.tag.outputs.version != ''
623644
with:

Makefile

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ endef
353353
LIB_NAMES = ios.dylib ios-sim.dylib macos.dylib
354354
FMWK_NAMES = ios-arm64 ios-arm64_x86_64-simulator macos-arm64_x86_64
355355
$(DIST_DIR)/%.xcframework: $(LIB_NAMES)
356-
@$(foreach i,1 2 3,\
356+
@$(foreach i,1 2,\
357357
lib=$(word $(i),$(LIB_NAMES)); \
358358
fmwk=$(word $(i),$(FMWK_NAMES)); \
359359
mkdir -p $(DIST_DIR)/$$fmwk/ai.framework/Headers; \
@@ -364,6 +364,21 @@ $(DIST_DIR)/%.xcframework: $(LIB_NAMES)
364364
mv $(DIST_DIR)/$$lib $(DIST_DIR)/$$fmwk/ai.framework/ai; \
365365
install_name_tool -id "@rpath/ai.framework/ai" $(DIST_DIR)/$$fmwk/ai.framework/ai; \
366366
)
367+
@lib=$(word 3,$(LIB_NAMES)); \
368+
fmwk=$(word 3,$(FMWK_NAMES)); \
369+
mkdir -p $(DIST_DIR)/$$fmwk/ai.framework/Versions/A/Headers; \
370+
mkdir -p $(DIST_DIR)/$$fmwk/ai.framework/Versions/A/Modules; \
371+
mkdir -p $(DIST_DIR)/$$fmwk/ai.framework/Versions/A/Resources; \
372+
cp src/sqlite-ai.h $(DIST_DIR)/$$fmwk/ai.framework/Versions/A/Headers; \
373+
printf "$(PLIST)" > $(DIST_DIR)/$$fmwk/ai.framework/Versions/A/Resources/Info.plist; \
374+
printf "$(MODULEMAP)" > $(DIST_DIR)/$$fmwk/ai.framework/Versions/A/Modules/module.modulemap; \
375+
mv $(DIST_DIR)/$$lib $(DIST_DIR)/$$fmwk/ai.framework/Versions/A/ai; \
376+
install_name_tool -id "@rpath/ai.framework/ai" $(DIST_DIR)/$$fmwk/ai.framework/Versions/A/ai; \
377+
ln -sf A $(DIST_DIR)/$$fmwk/ai.framework/Versions/Current; \
378+
ln -sf Versions/Current/ai $(DIST_DIR)/$$fmwk/ai.framework/ai; \
379+
ln -sf Versions/Current/Headers $(DIST_DIR)/$$fmwk/ai.framework/Headers; \
380+
ln -sf Versions/Current/Modules $(DIST_DIR)/$$fmwk/ai.framework/Modules; \
381+
ln -sf Versions/Current/Resources $(DIST_DIR)/$$fmwk/ai.framework/Resources;
367382
xcodebuild -create-xcframework $(foreach fmwk,$(FMWK_NAMES),-framework $(DIST_DIR)/$(fmwk)/ai.framework) -output $@
368383
rm -rf $(foreach fmwk,$(FMWK_NAMES),$(DIST_DIR)/$(fmwk))
369384

Package.swift

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,20 @@ let package = Package(
77
name: "ai",
88
platforms: [.macOS(.v11), .iOS(.v11)],
99
products: [
10-
// Products can be used to vend plugins, making them visible to other packages.
11-
.plugin(
12-
name: "aiPlugin",
13-
targets: ["aiPlugin"]),
1410
.library(
1511
name: "ai",
1612
targets: ["ai"])
1713
],
1814
targets: [
19-
// Build tool plugin that invokes the Makefile
20-
.plugin(
21-
name: "aiPlugin",
22-
capability: .buildTool(),
23-
path: "packages/swift/plugin"
15+
.binaryTarget(
16+
name: "aiBinary",
17+
url: "https://github.com/sqliteai/sqlite-ai/releases/download/1.0.3/ai-apple-xcframework-1.0.3.zip",
18+
checksum: "0000000000000000000000000000000000000000000000000000000000000000"
2419
),
25-
// ai library target
2620
.target(
2721
name: "ai",
28-
dependencies: [],
29-
path: "packages/swift/extension",
30-
plugins: ["aiPlugin"]
22+
dependencies: ["aiBinary"],
23+
path: "packages/swift"
3124
),
3225
]
33-
)
26+
)

packages/swift/ai.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// ai.swift
2+
// Provides the path to the ai SQLite extension for use with sqlite3_load_extension.
3+
4+
import Foundation
5+
6+
public struct ai {
7+
/// Returns the absolute path to the ai dylib for use with sqlite3_load_extension.
8+
public static var path: String {
9+
#if os(macOS)
10+
return Bundle.main.bundlePath + "/Contents/Frameworks/ai.framework/ai"
11+
#else
12+
return Bundle.main.bundlePath + "/Frameworks/ai.framework/ai"
13+
#endif
14+
}
15+
}

packages/swift/extension/ai.swift

Lines changed: 0 additions & 19 deletions
This file was deleted.

packages/swift/plugin/ai.swift

Lines changed: 0 additions & 61 deletions
This file was deleted.

src/sqlite-ai.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
extern "C" {
2525
#endif
2626

27-
#define SQLITE_AI_VERSION "1.0.2"
27+
#define SQLITE_AI_VERSION "1.0.3"
2828

2929
SQLITE_AI_API int sqlite3_ai_init (sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi);
3030

0 commit comments

Comments
 (0)