Skip to content

Commit e6d1c8b

Browse files
committed
fix(swift): use binary target and versioned macOS framework for Xcode 26 compatibility
1 parent 8b46806 commit e6d1c8b

File tree

7 files changed

+61
-116
lines changed

7 files changed

+61
-116
lines changed

.github/workflows/main.yml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ jobs:
177177
codesign --sign "${{ secrets.APPLE_TEAM_ID }}" --timestamp --options runtime dist/agent.xcframework
178178
ditto -c -k --keepParent dist/agent.xcframework dist/agent.xcframework.zip
179179
xcrun notarytool submit dist/agent.xcframework.zip --apple-id "${{ secrets.APPLE_ID }}" --password "${{ secrets.APPLE_PASSWORD }}" --team-id "${{ secrets.APPLE_TEAM_ID }}" --wait
180-
rm dist/agent.xcframework.zip
180+
rm -rf dist/agent.xcframework
181181
182182
- name: cleanup keychain for codesign
183183
if: matrix.os == 'macos-15'
@@ -262,7 +262,11 @@ jobs:
262262
if [[ "$name" != "agent-apple-xcframework" && "$name" != "agent-android-aar" ]]; then
263263
tar -czf "${name}-${VERSION}.tar.gz" -C "$folder" .
264264
fi
265-
if [[ "$name" != "agent-android-aar" ]]; then
265+
if [[ "$name" == "agent-apple-xcframework" ]]; then
266+
# Use the ditto-created zip that preserves macOS symlinks and extract for other steps
267+
cp "$folder/agent.xcframework.zip" "${name}-${VERSION}.zip"
268+
unzip -q "$folder/agent.xcframework.zip" -d "$folder/"
269+
elif [[ "$name" != "agent-android-aar" ]]; then
266270
(cd "$folder" && zip -rq "../../${name}-${VERSION}.zip" .)
267271
else
268272
cp "$folder"/*.aar "${name}-${VERSION}.aar"
@@ -356,6 +360,23 @@ jobs:
356360
echo " Main: @sqliteai/sqlite-agent@${{ steps.tag.outputs.version }}"
357361
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
358362
363+
- name: update Package.swift checksum and version
364+
if: steps.tag.outputs.version != ''
365+
run: |
366+
VERSION=${{ steps.tag.outputs.version }}
367+
ZIP="agent-apple-xcframework-${VERSION}.zip"
368+
if [ -f "$ZIP" ]; then
369+
CHECKSUM=$(swift package compute-checksum "$ZIP")
370+
URL="https://github.com/sqliteai/sqlite-agent/releases/download/${VERSION}/${ZIP}"
371+
sed -i "s|url: \".*apple-xcframework.*\"|url: \"${URL}\"|" Package.swift
372+
sed -i "s|checksum: \".*\"|checksum: \"${CHECKSUM}\"|" Package.swift
373+
git config --global user.email "$GITHUB_ACTOR@users.noreply.github.com"
374+
git config --global user.name "$GITHUB_ACTOR"
375+
git add Package.swift
376+
git commit -m "Update Package.swift checksum for ${VERSION} [skip ci]" || true
377+
git push origin main || true
378+
fi
379+
359380
- uses: softprops/action-gh-release@v2.2.1
360381
if: steps.tag.outputs.version != ''
361382
with:

Makefile

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ endef
208208
LIB_NAMES = ios.dylib ios-sim.dylib macos.dylib
209209
FMWK_NAMES = ios-arm64 ios-arm64_x86_64-simulator macos-arm64_x86_64
210210
$(DIST_DIR)/%.xcframework: $(LIB_NAMES)
211-
@$(foreach i,1 2 3,\
211+
@$(foreach i,1 2,\
212212
lib=$(word $(i),$(LIB_NAMES)); \
213213
fmwk=$(word $(i),$(FMWK_NAMES)); \
214214
mkdir -p $(DIST_DIR)/$$fmwk/agent.framework/Headers; \
@@ -219,6 +219,21 @@ $(DIST_DIR)/%.xcframework: $(LIB_NAMES)
219219
mv $(DIST_DIR)/$$lib $(DIST_DIR)/$$fmwk/agent.framework/agent; \
220220
install_name_tool -id "@rpath/agent.framework/agent" $(DIST_DIR)/$$fmwk/agent.framework/agent; \
221221
)
222+
@lib=$(word 3,$(LIB_NAMES)); \
223+
fmwk=$(word 3,$(FMWK_NAMES)); \
224+
mkdir -p $(DIST_DIR)/$$fmwk/agent.framework/Versions/A/Headers; \
225+
mkdir -p $(DIST_DIR)/$$fmwk/agent.framework/Versions/A/Modules; \
226+
mkdir -p $(DIST_DIR)/$$fmwk/agent.framework/Versions/A/Resources; \
227+
cp $(SRC_DIR)/sqlite-agent.h $(DIST_DIR)/$$fmwk/agent.framework/Versions/A/Headers; \
228+
printf "$(PLIST)" > $(DIST_DIR)/$$fmwk/agent.framework/Versions/A/Resources/Info.plist; \
229+
printf "$(MODULEMAP)" > $(DIST_DIR)/$$fmwk/agent.framework/Versions/A/Modules/module.modulemap; \
230+
mv $(DIST_DIR)/$$lib $(DIST_DIR)/$$fmwk/agent.framework/Versions/A/agent; \
231+
install_name_tool -id "@rpath/agent.framework/agent" $(DIST_DIR)/$$fmwk/agent.framework/Versions/A/agent; \
232+
ln -sf A $(DIST_DIR)/$$fmwk/agent.framework/Versions/Current; \
233+
ln -sf Versions/Current/agent $(DIST_DIR)/$$fmwk/agent.framework/agent; \
234+
ln -sf Versions/Current/Headers $(DIST_DIR)/$$fmwk/agent.framework/Headers; \
235+
ln -sf Versions/Current/Modules $(DIST_DIR)/$$fmwk/agent.framework/Modules; \
236+
ln -sf Versions/Current/Resources $(DIST_DIR)/$$fmwk/agent.framework/Resources;
222237
xcodebuild -create-xcframework $(foreach fmwk,$(FMWK_NAMES),-framework $(DIST_DIR)/$(fmwk)/agent.framework) -output $@
223238
rm -rf $(foreach fmwk,$(FMWK_NAMES),$(DIST_DIR)/$(fmwk))
224239

Package.swift

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
//
2-
// Package.swift
3-
// sqlite-agent
4-
//
5-
// Created by Gioele Cantoni on 05/11/25.
6-
//
7-
81
// swift-tools-version: 6.1
92
// The swift-tools-version declares the minimum version of Swift required to build this package.
103

@@ -14,27 +7,20 @@ let package = Package(
147
name: "agent",
158
platforms: [.macOS(.v11), .iOS(.v11)],
169
products: [
17-
// Products can be used to vend plugins, making them visible to other packages.
18-
.plugin(
19-
name: "agentPlugin",
20-
targets: ["agentPlugin"]),
2110
.library(
2211
name: "agent",
2312
targets: ["agent"])
2413
],
2514
targets: [
26-
// Build tool plugin that invokes the Makefile
27-
.plugin(
28-
name: "agentPlugin",
29-
capability: .buildTool(),
30-
path: "packages/swift/plugin"
15+
.binaryTarget(
16+
name: "agentBinary",
17+
url: "https://github.com/sqliteai/sqlite-agent/releases/download/0.1.8/agent-apple-xcframework-0.1.8.zip",
18+
checksum: "0000000000000000000000000000000000000000000000000000000000000000"
3119
),
32-
// agent library target
3320
.target(
3421
name: "agent",
35-
dependencies: [],
36-
path: "packages/swift/extension",
37-
plugins: ["agentPlugin"]
22+
dependencies: ["agentBinary"],
23+
path: "packages/swift"
3824
),
3925
]
4026
)

packages/swift/agent.swift

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

packages/swift/extension/agent.swift

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

packages/swift/plugin/agent.swift

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

src/sqlite-agent.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
extern "C" {
2828
#endif
2929

30-
#define SQLITE_AGENT_VERSION "0.1.7"
30+
#define SQLITE_AGENT_VERSION "0.1.8"
3131

3232
/**
3333
* SQLite extension entry point

0 commit comments

Comments
 (0)