Skip to content

Commit 1f31ac8

Browse files
committed
swift: add native SDK, codegen integration, demos, and CI
1 parent ab65b60 commit 1f31ac8

90 files changed

Lines changed: 13963 additions & 140 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Swift Procedure E2E
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- sdks/swift/**
7+
- crates/codegen/src/swift.rs
8+
- crates/codegen/src/lib.rs
9+
- crates/cli/src/subcommands/generate.rs
10+
- modules/module-test/**
11+
- tools/swift-procedure-e2e.sh
12+
- tools/check-swift-demo-bindings.sh
13+
- .github/workflows/swift-procedure-e2e.yml
14+
push:
15+
branches:
16+
- master
17+
paths:
18+
- sdks/swift/**
19+
- crates/codegen/src/swift.rs
20+
- crates/codegen/src/lib.rs
21+
- crates/cli/src/subcommands/generate.rs
22+
- modules/module-test/**
23+
- tools/swift-procedure-e2e.sh
24+
- tools/check-swift-demo-bindings.sh
25+
- .github/workflows/swift-procedure-e2e.yml
26+
workflow_dispatch:
27+
28+
concurrency:
29+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || format('sha-{0}', github.sha) }}
30+
cancel-in-progress: true
31+
32+
jobs:
33+
swift-procedure-e2e:
34+
name: Swift Procedure E2E (macOS)
35+
runs-on: macos-latest
36+
timeout-minutes: 45
37+
env:
38+
CARGO_TARGET_DIR: ${{ github.workspace }}/target
39+
steps:
40+
- name: Checkout sources
41+
uses: actions/checkout@v4
42+
43+
- name: Install Rust toolchain
44+
uses: dsherret/rust-toolchain-file@v1
45+
46+
- name: Set default rust toolchain
47+
run: rustup default $(rustup show active-toolchain | cut -d' ' -f1)
48+
49+
- name: Cache Rust dependencies
50+
uses: Swatinem/rust-cache@v2
51+
with:
52+
workspaces: ${{ github.workspace }}
53+
shared-key: spacetimedb
54+
save-if: false
55+
prefix-key: v1
56+
57+
- name: Install SpacetimeDB CLI from local checkout
58+
run: |
59+
export CARGO_HOME="$HOME/.cargo"
60+
echo "$CARGO_HOME/bin" >> "$GITHUB_PATH"
61+
cargo install --force --path crates/cli --locked --message-format=short
62+
cargo install --force --path crates/standalone --features allow_loopback_http_for_tests --locked --message-format=short
63+
ln -sf "$CARGO_HOME/bin/spacetimedb-cli" "$CARGO_HOME/bin/spacetime"
64+
65+
- name: Show toolchain versions
66+
run: |
67+
rustc --version
68+
cargo --version
69+
swiftc --version
70+
spacetime --version
71+
72+
- name: Verify generated Swift demo bindings are in sync
73+
run: tools/check-swift-demo-bindings.sh
74+
75+
- name: Start local SpacetimeDB server
76+
run: |
77+
spacetime start &
78+
disown
79+
sleep 5
80+
81+
- name: Run Swift procedure callback E2E
82+
run: tools/swift-procedure-e2e.sh

.github/workflows/swift-sdk.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Swift SDK
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- sdks/swift/**
7+
- demo/ninja-game/client-swift/**
8+
- demo/simple-module/client-swift/**
9+
- tools/swift-procedure-e2e.sh
10+
- .github/workflows/swift-sdk.yml
11+
push:
12+
branches:
13+
- master
14+
paths:
15+
- sdks/swift/**
16+
- demo/ninja-game/client-swift/**
17+
- demo/simple-module/client-swift/**
18+
- tools/swift-procedure-e2e.sh
19+
- .github/workflows/swift-sdk.yml
20+
workflow_dispatch:
21+
22+
concurrency:
23+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || format('sha-{0}', github.sha) }}
24+
cancel-in-progress: true
25+
26+
jobs:
27+
swift-sdk:
28+
name: Swift SDK (macOS)
29+
runs-on: macos-latest
30+
timeout-minutes: 30
31+
32+
steps:
33+
- name: Checkout sources
34+
uses: actions/checkout@v4
35+
36+
- name: Show Swift toolchain version
37+
run: swift --version
38+
39+
- name: Assert legacy Swift SDK path is removed
40+
shell: bash
41+
run: |
42+
if git grep -n "crates/swift-sdk" -- . ':(exclude).github/workflows/swift-sdk.yml'; then
43+
echo "Found legacy path references to crates/swift-sdk; expected sdks/swift."
44+
exit 1
45+
fi
46+
47+
- name: Test Swift SDK package
48+
run: swift test --package-path sdks/swift
49+
50+
- name: Build simple Swift demo client
51+
run: swift build --package-path demo/simple-module/client-swift
52+
53+
- name: Build ninja Swift demo client
54+
run: swift build --package-path demo/ninja-game/client-swift

crates/bindings-typescript/src/react/useTable.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,6 @@ export function useTable<TableDef extends UntypedTableDef>(
107107
// eslint-disable-next-line react-hooks/exhaustive-deps
108108
}, [connectionState, accessorName, querySql, subscribeApplied]);
109109

110-
// Invalidate the cached snapshot when computeSnapshot changes (e.g. when
111-
// subscribeApplied flips to true) so getSnapshot() recomputes on the next
112-
// render instead of returning a stale [rows, false] tuple.
113-
useEffect(() => {
114-
lastSnapshotRef.current = null;
115-
}, [computeSnapshot]);
116-
117110
useEffect(() => {
118111
const connection = connectionState.getConnection()!;
119112
if (connectionState.isActive && connection) {

0 commit comments

Comments
 (0)