Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ When in doubt about whether we will be interested in including a new feature, pl

This project uses [Mint](https://github.com/yonaskolb/Mint) to manage Swift linting tools (SwiftLint and SwiftFormat) at pinned versions via `platforms/swift/Mintfile`. This ensures consistent formatting across all contributors and CI.

**Shopify employees** (from `platforms/swift/`):
**Shopify employees** (from the repo root):

```bash
dev up
Expand Down
67 changes: 67 additions & 0 deletions dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ up:
- packages:
- quicktype
- rover
- mint
- xcbeautify
- jq
- ruby
- custom:
name: Install bundle packages
Expand All @@ -16,6 +19,37 @@ up:
([ -f "./platforms/android/samples/MobileBuyIntegration/.env" ] || exit 1)
meet: cd platforms/android && ./scripts/setup_env.sh

- custom:
name: Bootstrap Mint packages
met?: |
set -e
cd platforms/swift
expected_swiftlint="$(sed -n 's#^realm/SwiftLint@##p' Mintfile)"
expected_swiftformat="$(sed -n 's#^nicklockwood/SwiftFormat@##p' Mintfile)"
swiftlint_bin="$(mint which swiftlint)"
swiftformat_bin="$(mint which swiftformat)"
test -n "$expected_swiftlint"
test -n "$expected_swiftformat"
test "$("$swiftlint_bin" version)" = "$expected_swiftlint"
test "$("$swiftformat_bin" --version)" = "$expected_swiftformat"
meet: cd platforms/swift && mint bootstrap
- xcode:
version: "26.2"
runtimes:
ios:
- version: 23C54 # 26.2
architecture_variant: arm64
- custom:
name: Ensure Storefront.xcconfig file
met?: |
([ -f "./platforms/swift/Samples/MobileBuyIntegration/Storefront.xcconfig" ] || exit 1)
meet: cd platforms/swift && ./Scripts/ensure_storefront_config
- custom:
name: Setup entitlements
met?: |
([ -f "./platforms/swift/Samples/MobileBuyIntegration/MobileBuyIntegration/MobileBuyIntegration.entitlements" ] || exit 1;)
meet: cd platforms/swift && ./Scripts/setup_entitlements

open:
"GitHub": "https://github.com/Shopify/checkout-kit"
"Issues": "https://github.com/Shopify/checkout-kit/issues"
Expand All @@ -25,6 +59,7 @@ check:
android-license-headers: cd platforms/android && ./scripts/check_license_headers.rb
android-detekt: cd platforms/android && ./gradlew detekt
android-lint: cd platforms/android && ./gradlew lintRelease
swift-lint: cd platforms/swift && ./Scripts/lint

commands:
# Repo-wide
Expand Down Expand Up @@ -120,3 +155,35 @@ commands:
android-lint:
desc: Run Android lint
run: cd platforms/android && ./gradlew lintRelease

# Swift
swift:
desc: "Swift Checkout Kit commands"
subcommands:
lint:
desc: Check format and lint issues using SwiftLint and SwiftFormat
aliases: [style]
run: cd platforms/swift && ./Scripts/lint
fix:
desc: Automatically fix format and lint issues where possible
run: cd platforms/swift && ./Scripts/lint fix
build:
desc: Build Swift packages or sample apps
run: |
echo "Usage: dev swift build {packages|samples}"
subcommands:
packages:
desc: Build both ShopifyCheckoutKit and ShopifyAcceleratedCheckouts packages
run: |
cd platforms/swift
./Scripts/xcode_run build ShopifyCheckoutKit
./Scripts/xcode_run build ShopifyAcceleratedCheckouts
samples:
desc: Build all sample applications to verify integration
run: cd platforms/swift && ./Scripts/build_samples
test:
desc: |
`dev swift test` - Run all tests for the ShopifyCheckoutKit-Package.
`dev swift test <test_class_name>` - Run only the specified test class.
syntax: "[test_class_name]"
run: cd platforms/swift && ./Scripts/xcode_run test ShopifyCheckoutKit-Package "$1"
24 changes: 12 additions & 12 deletions platforms/swift/.cursor/rules/swift-development.mdc
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ alwaysApply: true
## Verification Commands

### Check your work systematically:
1. **Lint & Format** → `dev lint` (or `dev style`) - Checks for linting and stylistic errors
2. **Build Issues** → `dev build` - Checks for compilation issues
3. **Test Issues** → `dev test` - Checks for failing tests
1. **Lint & Format** → `dev swift lint` (or `dev swift style`) - Checks for linting and stylistic errors
2. **Build Issues** → `dev swift build` - Checks for compilation issues
3. **Test Issues** → `dev swift test` - Checks for failing tests

### Available dev commands:
**See `dev.yml` in project root for complete list of commands and descriptions.**

Key commands for verification:
- `dev lint` (alias: `dev style`) - Check format & lint issues
- `dev fix` - Auto-fix formatting and linting issues
- `dev build packages` - Build both packages
- `dev test packages` - Run all tests
- `dev swift lint` (alias: `dev swift style`) - Check format & lint issues
- `dev swift fix` - Auto-fix formatting and linting issues
- `dev swift build packages` - Build both packages
- `dev swift test` - Run all tests

## Concurrency Best Practices

Expand All @@ -50,22 +50,22 @@ actor QueryCache {
✅ DO: Run the appropriate dev command to verify

### After making changes:
- ALWAYS run `dev fix && dev lint` to check your code is formatted and written in our style.
- ALWAYS run `dev swift fix && dev swift lint` to check your code is formatted and written in our style.

## Example Workflow

```bash
# Make your Swift changes...

# Fix any auto-fixable issues
dev fix
dev swift fix

# Check for any remaining lint issues
dev lint
dev swift lint

# Verify it compiles
dev build
dev swift build

# Run tests if needed
dev test packages
dev swift test
```
8 changes: 4 additions & 4 deletions platforms/swift/Samples/MobileBuyIntegration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ From the **repo root**:
dev apollo codegen mobile-buy
```

This reads the schema + your `.graphql` files and regenerates the Swift code in `Generated/`. The command also runs `dev fix` to auto-format the output.
This reads the schema + your `.graphql` files and regenerates the Swift code in `Generated/`. The command also runs `dev swift fix` to auto-format the output.

### 5. Build and fix any issues

Expand All @@ -138,9 +138,9 @@ All commands are run from the **repo root** (`checkout-kit/`):
| `dev apollo download_schema mobile-buy` | Download the Storefront API schema for this sample app |
| `dev apollo codegen mobile-buy` | Regenerate Swift types from `.graphql` files |
| `dev apollo codegen all` | Regenerate for all sample apps |
| `dev style` | Run SwiftLint + SwiftFormat checks |
| `dev fix` | Auto-fix lint/format issues |
| `dev build samples` | Build all sample apps |
| `dev swift style` | Run SwiftLint + SwiftFormat checks |
| `dev swift fix` | Auto-fix lint/format issues |
| `dev swift build samples` | Build all sample apps |

## Key files

Expand Down
2 changes: 1 addition & 1 deletion platforms/swift/Scripts/apollo_codegen
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ case "$APP" in
;;
esac

/opt/dev/bin/dev fix
/opt/dev/bin/dev swift fix
2 changes: 1 addition & 1 deletion platforms/swift/Scripts/lint
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ print_linting_error() {
echo "❌ $tool_name detected issues that need to be fixed."
if [[ "$MODE" == "check" ]]; then
echo "🔧 How to fix:"
echo " Shopify employee? Run 'dev fix' and resolve remaining issues"
echo " Shopify employee? Run 'dev swift fix' and resolve remaining issues"
echo " Not a Shopify employee? Run './Scripts/lint fix' and resolve remaining issues"
else
echo "🔧 These files will need to be fixed manually"
Expand Down
70 changes: 0 additions & 70 deletions platforms/swift/dev.yml

This file was deleted.

Loading