Skip to content

Commit 52d188d

Browse files
committed
fix(swift): use binary target and versioned macOS framework for Xcode 26 compatibility
1 parent faeab43 commit 52d188d

File tree

7 files changed

+62
-97
lines changed

7 files changed

+62
-97
lines changed

.github/workflows/main.yml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ jobs:
135135
codesign --sign "${{ secrets.APPLE_TEAM_ID }}" --timestamp --options runtime dist/js.xcframework # Then sign the xcframework wrapper
136136
ditto -c -k --keepParent dist/js.xcframework dist/js.xcframework.zip
137137
xcrun notarytool submit dist/js.xcframework.zip --apple-id "${{ secrets.APPLE_ID }}" --password "${{ secrets.APPLE_PASSWORD }}" --team-id "${{ secrets.APPLE_TEAM_ID }}" --wait
138-
rm dist/js.xcframework.zip
138+
rm -rf dist/js.xcframework
139139
140140
- name: cleanup keychain for codesign
141141
if: matrix.os == 'macos-15'
@@ -220,7 +220,11 @@ jobs:
220220
if [[ "$name" != "js-apple-xcframework" && "$name" != "js-android-aar" ]]; then
221221
tar -czf "${name}-${VERSION}.tar.gz" -C "$folder" .
222222
fi
223-
if [[ "$name" != "js-android-aar" ]]; then
223+
if [[ "$name" == "js-apple-xcframework" ]]; then
224+
# Use the ditto-created zip that preserves macOS symlinks and extract for other steps
225+
cp "$folder/js.xcframework.zip" "${name}-${VERSION}.zip"
226+
unzip -q "$folder/js.xcframework.zip" -d "$folder/"
227+
elif [[ "$name" != "js-android-aar" ]]; then
224228
(cd "$folder" && zip -rq "../../${name}-${VERSION}.zip" .)
225229
else
226230
cp "$folder"/*.aar "${name}-${VERSION}.aar"
@@ -315,6 +319,23 @@ jobs:
315319
echo " Platform packages: 7"
316320
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
317321
322+
- name: update Package.swift checksum and version
323+
if: steps.tag.outputs.version != ''
324+
run: |
325+
VERSION=${{ steps.tag.outputs.version }}
326+
ZIP="js-apple-xcframework-${VERSION}.zip"
327+
if [ -f "$ZIP" ]; then
328+
CHECKSUM=$(swift package compute-checksum "$ZIP")
329+
URL="https://github.com/sqliteai/sqlite-js/releases/download/${VERSION}/${ZIP}"
330+
sed -i "s|url: \".*apple-xcframework.*\"|url: \"${URL}\"|" Package.swift
331+
sed -i "s|checksum: \".*\"|checksum: \"${CHECKSUM}\"|" Package.swift
332+
git config --global user.email "$GITHUB_ACTOR@users.noreply.github.com"
333+
git config --global user.name "$GITHUB_ACTOR"
334+
git add Package.swift
335+
git commit -m "Update Package.swift checksum for ${VERSION} [skip ci]" || true
336+
git push origin main || true
337+
fi
338+
318339
- uses: softprops/action-gh-release@v2.2.1
319340
if: steps.tag.outputs.version != ''
320341
with:

Makefile

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ endef
205205
LIB_NAMES = ios.dylib ios-sim.dylib macos.dylib
206206
FMWK_NAMES = ios-arm64 ios-arm64_x86_64-simulator macos-arm64_x86_64
207207
$(DIST_DIR)/%.xcframework: $(LIB_NAMES)
208-
@$(foreach i,1 2 3,\
208+
@$(foreach i,1 2,\
209209
lib=$(word $(i),$(LIB_NAMES)); \
210210
fmwk=$(word $(i),$(FMWK_NAMES)); \
211211
mkdir -p $(DIST_DIR)/$$fmwk/js.framework/Headers; \
@@ -216,6 +216,21 @@ $(DIST_DIR)/%.xcframework: $(LIB_NAMES)
216216
mv $(DIST_DIR)/$$lib $(DIST_DIR)/$$fmwk/js.framework/js; \
217217
install_name_tool -id "@rpath/js.framework/js" $(DIST_DIR)/$$fmwk/js.framework/js; \
218218
)
219+
@lib=$(word 3,$(LIB_NAMES)); \
220+
fmwk=$(word 3,$(FMWK_NAMES)); \
221+
mkdir -p $(DIST_DIR)/$$fmwk/js.framework/Versions/A/Headers; \
222+
mkdir -p $(DIST_DIR)/$$fmwk/js.framework/Versions/A/Modules; \
223+
mkdir -p $(DIST_DIR)/$$fmwk/js.framework/Versions/A/Resources; \
224+
cp src/sqlitejs.h $(DIST_DIR)/$$fmwk/js.framework/Versions/A/Headers; \
225+
printf "$(PLIST)" > $(DIST_DIR)/$$fmwk/js.framework/Versions/A/Resources/Info.plist; \
226+
printf "$(MODULEMAP)" > $(DIST_DIR)/$$fmwk/js.framework/Versions/A/Modules/module.modulemap; \
227+
mv $(DIST_DIR)/$$lib $(DIST_DIR)/$$fmwk/js.framework/Versions/A/js; \
228+
install_name_tool -id "@rpath/js.framework/js" $(DIST_DIR)/$$fmwk/js.framework/Versions/A/js; \
229+
ln -sf A $(DIST_DIR)/$$fmwk/js.framework/Versions/Current; \
230+
ln -sf Versions/Current/js $(DIST_DIR)/$$fmwk/js.framework/js; \
231+
ln -sf Versions/Current/Headers $(DIST_DIR)/$$fmwk/js.framework/Headers; \
232+
ln -sf Versions/Current/Modules $(DIST_DIR)/$$fmwk/js.framework/Modules; \
233+
ln -sf Versions/Current/Resources $(DIST_DIR)/$$fmwk/js.framework/Resources;
219234
xcodebuild -create-xcframework $(foreach fmwk,$(FMWK_NAMES),-framework $(DIST_DIR)/$(fmwk)/js.framework) -output $@
220235
rm -rf $(foreach fmwk,$(FMWK_NAMES),$(DIST_DIR)/$(fmwk))
221236

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: "js",
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: "jsPlugin",
13-
targets: ["jsPlugin"]),
1410
.library(
1511
name: "js",
1612
targets: ["js"])
1713
],
1814
targets: [
19-
// Build tool plugin that invokes the Makefile
20-
.plugin(
21-
name: "jsPlugin",
22-
capability: .buildTool(),
23-
path: "packages/swift/plugin"
15+
.binaryTarget(
16+
name: "jsBinary",
17+
url: "https://github.com/sqliteai/sqlite-js/releases/download/1.3.2/js-apple-xcframework-1.3.2.zip",
18+
checksum: "0000000000000000000000000000000000000000000000000000000000000000"
2419
),
25-
// js library target
2620
.target(
2721
name: "js",
28-
dependencies: [],
29-
path: "packages/swift/extension",
30-
plugins: ["jsPlugin"]
22+
dependencies: ["jsBinary"],
23+
path: "packages/swift"
3124
),
3225
]
33-
)
26+
)

packages/swift/extension/js.swift

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

packages/swift/js.swift

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

packages/swift/plugin/js.swift

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

src/sqlitejs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include "sqlite3.h"
1717
#endif
1818

19-
#define SQLITE_JS_VERSION "1.3.1"
19+
#define SQLITE_JS_VERSION "1.3.2"
2020

2121
int sqlite3_js_init (sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi);
2222
const char *sqlitejs_version (void);

0 commit comments

Comments
 (0)