No description
|
Some checks failed
Build and Publish / build-and-publish (push) Failing after 43s
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com> |
||
|---|---|---|
| .forgejo/workflows | ||
| ci | ||
| makefiles | ||
| scripts | ||
| swiftlint | ||
| package.json | ||
| README.md | ||
@lilith/swift-tooling
Shared Swift development tooling for Lilith Platform projects.
Contents
@swift/
├── swiftlint/
│ ├── base.yml # Core SwiftLint rules
│ └── macos-app.yml # macOS app-specific rules
├── makefiles/
│ └── base.mk # Makefile with lint, build, test targets
├── ci/
│ └── gitlab-swift-lint.yml # GitLab CI template (Linux Docker)
└── scripts/
└── install-tools.sh # Install SwiftLint/SwiftFormat
Quick Start
1. Install Tools (macOS)
./scripts/install-tools.sh
# Or manually:
brew install swiftlint swiftformat
2. Add to Your Swift Project
Create .swiftlint.yml in your project:
parent_config: ~/Code/@packages/@swift/swiftlint/macos-app.yml
# Project-specific overrides (optional)
excluded:
- .build
- DerivedData
Create Makefile:
SWIFT_PACKAGE_NAME = YourAppName
include ~/Code/@packages/@swift/makefiles/base.mk
3. Use Make Targets
make help # Show all targets
make lint # Run SwiftLint
make lint-fix # Auto-fix lint issues
make build # Build debug
make build-release # Build release
make test # Run tests
make clean # Clean build artifacts
GitLab CI Integration
Add to your .gitlab-ci.yml:
your-app:swift-lint:
stage: test
image: ghcr.io/realm/swiftlint:0.54.0
script:
- cd path/to/swift/project
- swiftlint lint --config .swiftlint.yml --strict
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
changes:
- path/to/swift/project/**/*.swift
SwiftLint Rules
Base Rules (base.yml)
- Force cast/try/unwrap detection
- Sorted imports
- Closure spacing and formatting
- Function parameter limits (6 warn, 8 error)
- Cyclomatic complexity (10 warn, 20 error)
- No print() statements (use NSLog/os.Logger)
macOS App Rules (macos-app.yml)
Extends base with:
- Accessibility label requirements
- Private outlet enforcement
- Async/await preference over DispatchQueue
- Stricter nesting limits
Linux Compatibility
| Tool | Linux | Notes |
|---|---|---|
| SwiftLint | Yes | Docker or manual install |
| SwiftFormat | Yes | Requires Swift toolchain |
| swift build | Partial | macOS frameworks unavailable |
| swift test | No | Tests need macOS APIs |
Custom Rules
The collective enforces these project conventions:
- No print() - Use
NSLog()oros.Loggerfor production - Prefer async/await - Over
DispatchQueue.async - Avoid force unwrap - Use guard/if-let
Updating
To update SwiftLint rules across all projects, edit the configs in this package. Projects using parent_config will automatically pick up changes.
Lilith Platform Swift Tooling v1.0.0