Skip to content

Commit

Permalink
feat(swiftsdk): swift sdk scaffolding
Browse files Browse the repository at this point in the history
  • Loading branch information
jackpooleyml committed Dec 12, 2024
1 parent 94087ad commit 20a7601
Show file tree
Hide file tree
Showing 36 changed files with 1,743 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .github/package.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "ZKsyncSSO"
BuildableName = "ZKsyncSSO"
BlueprintName = "ZKsyncSSO"
ReferencedContainer = "container:../platforms/swift/ZKsyncSSO">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "NO"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "ZKsyncSSOTests"
BuildableName = "ZKsyncSSOTests"
BlueprintName = "ZKsyncSSOTests"
ReferencedContainer = "container:../platforms/swift/ZKsyncSSO">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "ZKsyncSSOTests"
BuildableName = "ZKsyncSSOTests"
BlueprintName = "ZKsyncSSOTests"
ReferencedContainer = "container:../platforms/swift/ZKsyncSSO">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "ZKsyncSSO"
BuildableName = "ZKsyncSSO"
BlueprintName = "ZKsyncSSO"
ReferencedContainer = "container:../platforms/swift/ZKsyncSSO">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
45 changes: 45 additions & 0 deletions .github/workflows/ci-swift.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Swift CI

on:
push:
paths:
- 'platforms/**'

jobs:
swift-sdk:
name: Swift Package - latest
runs-on: macos-15
strategy:
matrix:
config:
- debug
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
- run: rustup update stable && rustup default stable
- name: Select Xcode 16.1
run: sudo xcode-select -s /Applications/Xcode_16.1.app
- name: Select Simulator
run: |
UDID=$(xcrun simctl list devices | awk '/-- iOS 18.1 --/{flag=1; next} /--/{flag=0} flag' | grep "iPhone 16 Pro" | awk -F '[()]' '{print $2}' | head -1)
if [ -z "$UDID" ]; then
echo "Simulator not found!" >&2
exit 1
fi
echo "Simulator UDID: $UDID"
echo "SIMULATOR_UDID=$UDID" >> $GITHUB_ENV
- name: Install swiftformat
run: brew install swiftformat
- name: Build bindings
run: sh platforms/shared/zksync-sso/crates/ffi/build-swift-framework.sh
- name: Build & test Swift SDK
run: |
xcodebuild test \
-skipMacroValidation \
-configuration debug \
-workspace .github/package.xcworkspace \
-scheme zksyncsso \
-destination "platform=iOS Simulator,id=${{ env.SIMULATOR_UDID }}" || exit 1
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: CI

on:
pull_request:
paths-ignore:
- 'platforms/**'
workflow_dispatch:

jobs:
Expand Down Expand Up @@ -166,4 +168,3 @@ jobs:
- name: Run contract test
run: pnpm test
working-directory: packages/contracts

16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,19 @@ playwright/.cache/
.DS_Store

dist

# Rust
debug/
target/
Cargo.lock

# Swift
xcuserdata/
*.hmap
*.ipa
*.dSYM.zip
*.dSYM
timeline.xctimeline
playground.xcworkspace
.build/
out/
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ deployments-zk
**/*.tsx
**/*.mjs
**/*.cjs

# Ignore Swift/Rust files
platforms/*
7 changes: 7 additions & 0 deletions .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"**/test-results/**",
"**/playwright-report/**",
"**/blob-report/**",
"**/playwright/.cache/**"
"**/playwright/.cache/**",
"platforms/**"
],
"caseSensitive": true,
"dictionaries": [
Expand Down
11 changes: 11 additions & 0 deletions platforms/shared/zksync-sso/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[workspace]
members = ["crates/*"]
resolver = "2"

[workspace.package]
version = "0.1.0"
edition = "2021"
rust-version = "1.83"
license = "Apache-2.0"

[workspace.dependencies]
9 changes: 9 additions & 0 deletions platforms/shared/zksync-sso/crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "cli"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true

[dependencies]
sdk = { path = "../sdk" }
3 changes: 3 additions & 0 deletions platforms/shared/zksync-sso/crates/cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
println!("{}", format!("{}", sdk::add(1, 1)));
}
16 changes: 16 additions & 0 deletions platforms/shared/zksync-sso/crates/ffi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "ffi"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true

[lib]
crate-type = ["staticlib"]

[dependencies]
uniffi = { version = "0.28.3", features = ["cli"] }
sdk = { path = "../sdk" }

[build-dependencies]
uniffi = { version = "0.28.3", features = ["build", "cli"] }
Loading

0 comments on commit 20a7601

Please sign in to comment.