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
38 changes: 19 additions & 19 deletions .github/workflows/VerifyChanges.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Select Xcode 16.4
- name: Select Xcode 26.0.0
run: |
sudo xcode-select -s /Applications/Xcode_16.4.0.app
sudo xcode-select -s /Applications/Xcode_26.0.0.app
- name: Lint
run: |
Scripts/lint
Expand All @@ -28,22 +28,22 @@ jobs:
fail-fast: false
matrix:
include:
- platform: iOS
xcode_destination: "platform=iOS Simulator,name=iPhone 16 Pro"
xcode_project: "DevKeychain.xcodeproj"
xcode_scheme: "DevKeychainApp"
# - platform: iOS
# xcode_destination: "platform=iOS Simulator,name=iPhone 16 Pro"
# xcode_project: "DevKeychain.xcodeproj"
# xcode_scheme: "DevKeychainApp"
- platform: macOS
xcode_destination: "platform=macOS,arch=arm64"
xcode_project: ""
xcode_scheme: "DevKeychain"
- platform: tvOS
xcode_destination: "platform=tvOS Simulator,name=Apple TV 4K (3rd generation)"
xcode_project: ""
xcode_scheme: "DevKeychain"
- platform: watchOS
xcode_destination: "platform=watchOS Simulator,name=Apple Watch Series 10 (46mm)"
xcode_project: ""
xcode_scheme: "DevKeychain"
# - platform: tvOS
# xcode_destination: "platform=tvOS Simulator,name=Apple TV 4K (3rd generation)"
# xcode_project: ""
# xcode_scheme: "DevKeychain"
# - platform: watchOS
# xcode_destination: "platform=watchOS Simulator,name=Apple Watch Series 10 (46mm)"
# xcode_project: ""
# xcode_scheme: "DevKeychain"
env:
DEV_BUILDS: DevBuilds/Sources
XCCOV_PRETTY_VERSION: 1.2.0
Expand Down Expand Up @@ -80,9 +80,9 @@ jobs:
**/*.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
Package.resolved
verbose: true
- name: Select Xcode 16.4
- name: Select Xcode 26.0.0
run: |
sudo xcode-select -s /Applications/Xcode_16.4.0.app
sudo xcode-select -s /Applications/Xcode_26.0.0.app
- name: Build for Testing
run: |
"$DEV_BUILDS"/build_and_test.sh --action build-for-testing
Expand Down Expand Up @@ -128,9 +128,9 @@ jobs:
- name: Download xccovPretty output
uses: actions/download-artifact@v4
with:
name: xccovPrettyOutput-iOS
name: xccovPrettyOutput-macOS
- name: Post Code Coverage Comment
uses: thollander/actions-comment-pull-request@v3
with:
file-path: xccovPretty-iOS.output
comment-tag: codeCoverage-iOS
file-path: xccovPretty-macOS.output
comment-tag: codeCoverage-macOS
1 change: 1 addition & 0 deletions .swift-format
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"lineBreakBetweenDeclarationAttributes": false,
"lineLength": 120,
"maximumBlankLines": 2,
"multilineTrailingCommaBehavior": "alwaysUsed",
"multiElementCollectionTrailingCommas": true,
"noAssignmentInExpressions": {
"allowedFunctions": []
Expand Down

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
@@ -1,5 +1,5 @@
//
// StandardKeychainServicesTests.swift
// StandardKeychainServicesIntegrationTests.swift
// DevKeychainAppTests
//
// Created by Prachi Gauriar on 6/22/25.
Expand Down
52 changes: 35 additions & 17 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ repository.

DevKeychain is a Swift package providing a modern, type-safe interface to Apple's keychain
services. It supports iOS 18+, macOS 15+, tvOS 18+, visionOS 2+, and watchOS 11+, requiring
Swift 6.1 toolchain.
Swift 6.2+ toolchain.


## Common Development Commands
Expand Down Expand Up @@ -121,18 +121,22 @@ Uses **Swift Testing** framework with comprehensive mocking:

## CI/CD Configuration

The project uses GitHub Actions with comprehensive testing:
The project uses GitHub Actions for continuous integration:

- Multi-platform testing (iOS, macOS, tvOS, watchOS)
- Code coverage reporting with xccovPretty
- Swift-format validation
- Test plans in `Build Support/Test Plans/`
- **Linting**: Automatically checks code formatting on all pull requests using `swift format`
- **Testing**: Runs tests on macOS (iOS, tvOS, and watchOS testing are disabled in CI due to
reliability issues)
- **Coverage**: Generates code coverage reports using xccovPretty

For comprehensive cross-platform testing, developers should run `Scripts/test-all-platforms`
locally or rely on the pre-push git hook which automatically runs all platform tests before
pushing changes.


## Platform Requirements

- Swift 6.1 toolchain required
- Xcode 16.4 for CI/CD
- Swift 6.2+ toolchain required
- Xcode 26.0 for CI/CD
- Apple platforms only (iOS 18+, macOS 15+, tvOS 18+, visionOS 2+, watchOS 11+)
- Uses modern Swift concurrency features

Expand All @@ -144,23 +148,37 @@ The `Scripts/` directory contains utility scripts for development workflow autom
### Available Scripts

**`Scripts/install-git-hooks`**:
- Installs pre-commit git hooks that automatically run lint checks
- Creates `.git/hooks/pre-commit` that calls `Scripts/lint`
- Prevents commits with formatting issues
- Run once per repository to set up automated code quality checks
- Installs pre-commit and pre-push git hooks for automated quality checks
- Creates `.git/hooks/pre-commit` that calls `Scripts/lint` for formatting validation
- Creates `.git/hooks/pre-push` that calls `Scripts/test-all-platforms` for comprehensive testing
- Prevents commits with formatting issues and pushes with test failures
- Run once per repository to set up automated code quality and testing workflow

**`Scripts/lint`**:
- Runs swift-format lint validation with strict mode enabled
- Checks `App/`, `Sources/`, and `Tests/` directories recursively
- Returns non-zero exit code if formatting issues are found
- Used by pre-commit hooks and can be run manually for code quality verification

**`Scripts/test-all-platforms`**:
- Runs comprehensive tests across all supported Apple platforms
- Tests on iOS Simulator (iPhone 16 Pro), macOS, tvOS Simulator (Apple TV 4K), and watchOS
Simulator (Apple Watch Series 10)
- Uses different project configurations: DevKeychainApp scheme for iOS, DevKeychain scheme for
other platforms
- Provides colored output with timestamps and clear success/failure indicators
- Returns non-zero exit code if any platform tests fail
- Essential for local cross-platform validation since CI only tests macOS

### Usage Patterns

- Run `Scripts/install-git-hooks` after cloning the repository
- Pre-commit hooks will automatically run `Scripts/lint` before each commit
- Manual lint checking: `Scripts/lint`
- Both scripts work from any directory by calculating repository root path
- Run `Scripts/install-git-hooks` after cloning the repository for complete automation
- Pre-commit hooks automatically run `Scripts/lint` before each commit
- Pre-push hooks automatically run `Scripts/test-all-platforms` before each push
- Manual operations:
- Code formatting check: `Scripts/lint`
- Cross-platform testing: `Scripts/test-all-platforms`
- All scripts work from any directory by calculating repository root path


## Key Files for Understanding
Expand All @@ -172,4 +190,4 @@ The `Scripts/` directory contains utility scripts for development workflow autom
- `Tests/DevKeychainTests/Testing Helpers/`: Mock implementations and test utilities
- `Package.swift`: Dependencies and platform requirements
- `.swift-format`: Code formatting configuration
- `Scripts/`: Development workflow automation scripts
- `Scripts/`: Development workflow automation scripts
6 changes: 3 additions & 3 deletions Package.resolved

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

4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version: 6.1
// swift-tools-version: 6.2

import PackageDescription

Expand All @@ -23,7 +23,7 @@ let package = Package(
)
],
dependencies: [
.package(url: "https://github.com/DevKitOrganization/DevTesting", from: "1.0.0-beta.10")
.package(url: "https://github.com/DevKitOrganization/DevTesting", from: "1.0.0-beta.11")
],
targets: [
.target(
Expand Down
31 changes: 24 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,43 @@
# DevKeychain

DevKeychain is a small Swift package that provides a Swift interface to Apple’s keychain services. It is fully
documented and tested and supports iOS 18+, macOS 15+, tvOS 18+, visionOS 2+, and watchOS 11+.
DevKeychain is a small Swift package that provides a Swift interface to Apple’s keychain services.
It is fully documented and tested and supports iOS 18+, macOS 15+, tvOS 18+, visionOS 2+, and
watchOS 11+.

View our [changelog](CHANGELOG.md) to see what’s new.


## Development Requirements

DevKeychain requires a Swift 6.1 toolchain to build. We only test on Apple platforms. We follow
the [Swift API Design Guidelines][SwiftAPIDesignGuidelines]. We take pride in the fact that our
public interfaces are fully documented and tested. We aim for overall test coverage over 99%.
DevKeychain requires a Swift 6.2+ toolchain to build. We only test on Apple platforms. We follow the
[Swift API Design Guidelines][SwiftAPIDesignGuidelines]. We take pride in the fact that our public
interfaces are fully documented and tested. We aim for overall test coverage over 99%.

[SwiftAPIDesignGuidelines]: https://swift.org/documentation/api-design-guidelines/


### Development Setup

To set up the development environment:

1. Run `Scripts/install-git-hooks` to install pre-commit hooks that automatically check code
formatting.
1. Run `Scripts/install-git-hooks` to install git hooks that automatically check code
formatting on commits and run comprehensive tests before pushing.
2. Use `Scripts/lint` to manually check code formatting at any time.
3. Use `Scripts/test-all-platforms` to run tests on all supported platforms locally.


## Continuous Integration

DevKeychain uses GitHub Actions for continuous integration. The CI pipeline:

- **Linting**: Automatically checks code formatting on all pull requests using `swift format`
- **Testing**: Runs tests on macOS (iOS, tvOS, and watchOS testing are disabled in CI due to
reliability issues)
- **Coverage**: Generates code coverage reports using xccovPretty

For comprehensive cross-platform testing, developers should run `Scripts/test-all-platforms`
locally or rely on the pre-push git hook which automatically runs all platform tests before
pushing changes.


## Bugs and Feature Requests
Expand Down
33 changes: 33 additions & 0 deletions Scripts/install-git-hooks
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,41 @@ EOF
echo "Pre-commit hook installed successfully!"
}

# Function to install the pre-push hook
install_pre_push_hook() {
local pre_push_hook="$REPO_ROOT/.git/hooks/pre-push"

echo "Installing pre-push hook..."

cat > "$pre_push_hook" << 'EOF'
#!/bin/bash

# Get the directory where this hook is located
HOOK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

# Go to the repository root (two levels up from .git/hooks)
REPO_ROOT="$(dirname "$(dirname "$HOOK_DIR")")"

# Run the test-all-platforms script
echo "Running tests on all platforms..."
if ! "$REPO_ROOT/Scripts/test-all-platforms"; then
echo "Platform tests failed. Please fix issues before pushing."
exit 1
fi

echo "All platform tests passed."
EOF

chmod +x "$pre_push_hook"
echo "Pre-push hook installed successfully!"
}

# Install the pre-commit hook
install_pre_commit_hook

# Install the pre-push hook
install_pre_push_hook

echo "All git hooks installed successfully!"
echo "The pre-commit hook will run 'Scripts/lint' before each commit."
echo "The pre-push hook will run 'Scripts/test-all-platforms' before each push."
68 changes: 68 additions & 0 deletions Scripts/test-all-platforms
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/bin/bash

set -euo pipefail

# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color

# Function to print colored output
print_status() {
echo -e "${YELLOW}[$(date +'%H:%M:%S')] $1${NC}"
}

print_success() {
echo -e "${GREEN}✓ $1${NC}"
}

print_error() {
echo -e "${RED}✗ $1${NC}"
}

# Platforms to test
PLATFORMS=(
"iOS Simulator,name=iPhone 16 Pro"
"macOS"
"tvOS Simulator,name=Apple TV 4K"
"watchOS Simulator,name=Apple Watch Series 10"
)

DEFAULT_SCHEME="DevKeychain"
IOS_PROJECT="DevKeychain.xcodeproj"
IOS_SCHEME="DevKeychainApp"
FAILED_PLATFORMS=()

print_status "Starting tests on all platforms..."
echo

for platform in "${PLATFORMS[@]}"; do
platform_name=$(echo "$platform" | cut -d',' -f1)
print_status "Testing on $platform_name..."

# Set project specifier based on platform
if [[ "$platform_name" == "iOS Simulator" ]]; then
PROJECT_SPECIFIER="-project $IOS_PROJECT -scheme $IOS_SCHEME"
else
PROJECT_SPECIFIER="-scheme $DEFAULT_SCHEME"
fi

if xcodebuild test $PROJECT_SPECIFIER -destination "platform=$platform"; then
print_success "$platform_name tests passed"
else
print_error "$platform_name tests failed"
FAILED_PLATFORMS+=("$platform_name")
fi
echo
done

# Summary
echo "=========================="
if [ ${#FAILED_PLATFORMS[@]} -eq 0 ]; then
print_success "All platform tests passed!"
exit 0
else
print_error "Tests failed on: ${FAILED_PLATFORMS[*]}"
exit 1
fi
Loading
Loading