# Verify Xcode installation
xcodebuild -version
# Verify Swift version
swift --version # Should be 5.10+git clone <repository-url>
cd rightlayout
swift build
swift test- Follow Swift API Design Guidelines
- Use SwiftLint for consistency (optional)
- 4 spaces for indentation
- Max line length: 120 characters
- Types: PascalCase (
LanguageDetector,CorrectionEngine) - Functions: camelCase (
detectLanguage,correctText) - Constants: camelCase (
preferredLanguage,isEnabled) - Actors: Suffix with
Actorif ambiguous
- Use
actorfor mutable shared state - Use
@MainActorfor UI-related code - Avoid
@unchecked Sendableunless absolutely necessary - Document thread safety assumptions
- Update Language enum (
Core/LanguageDetector.swift):
enum Language: String, CaseIterable {
case russian = "ru"
case english = "en"
case hebrew = "he"
case german = "de" // New language
}- Add character mappings (
Core/LayoutMapper.swift):
private static let deToEn: [Character: Character] = [
"ä": "a", "ö": "o", "ü": "u", // etc.
]- Update language hints (
Core/LanguageDetector.swift):
recognizer.languageHints = [
.russian: 0.25,
.english: 0.25,
.hebrew: 0.25,
.german: 0.25
]- Add tests (
Tests/LayoutMapperTests.swift):
func testGermanToEnglish() {
let result = LayoutMapper.convert("äöü", from: .german, to: .english)
XCTAssertEqual(result, "aou")
}- Create SwiftUI view in
Sources/UI/ - Use
@StateObjectforSettingsManager - Follow existing view patterns
- Test on macOS Sonoma and Sequoia
- Add property (
Settings/SettingsManager.swift):
@Published var newSetting: Bool {
didSet { UserDefaults.standard.set(newSetting, forKey: "newSetting") }
}- Initialize in init:
self.newSetting = UserDefaults.standard.object(forKey: "newSetting") as? Bool ?? false- Add UI (
UI/SettingsView.swift):
Toggle("New Setting", isOn: $settings.newSetting)# All tests
swift test
# Specific test suite
swift test --filter LanguageDetectorTests
# With coverage
swift test --enable-code-coverageimport XCTest
@testable import RightLayout
final class MyTests: XCTestCase {
func testFeature() async throws {
// Arrange
let detector = LanguageDetector()
// Act
let result = await detector.detect("test")
// Assert
XCTAssertEqual(result, .english)
}
}- Core logic: >90%
- UI: Manual testing
- Integration: Manual scenarios
# Stream logs in real-time
log stream --predicate 'subsystem == "com.chernistry.rightlayout"' --level debug- Open
Package.swiftin Xcode - Set breakpoints
- Run with ⌘R
- Use Instruments for profiling
Event tap not working:
- Check Accessibility permissions
- Verify app is not sandboxed
- Check Console.app for errors
Language detection inaccurate:
- Add logging in
LanguageDetector.detect() - Test with longer text samples
- Adjust language hints
High CPU usage:
- Profile with Instruments
- Check event processing frequency
- Optimize buffer management
- Event capture: <5ms
- Language detection: <10ms
- Total correction: <50ms
- Keep history limited (50 records)
- Clear buffers after processing
- Avoid retaining event objects
# Build for profiling
swift build -c release
# Profile with Instruments
instruments -t "Time Profiler" .build/release/RightLayout- Fork the repository
- Create branch:
git checkout -b feature/my-feature - Make changes: Follow code style
- Add tests: Ensure coverage
- Run tests:
swift test - Commit: Use descriptive messages
- Push:
git push origin feature/my-feature - Create PR: Describe changes clearly
- Code follows style guide
- Tests added/updated
- All tests pass
- Documentation updated
- No new warnings
- Performance impact considered
- Correctness: Does it work as intended?
- Performance: Any latency impact?
- Security: Any privacy concerns?
- Concurrency: Thread-safe?
- Tests: Adequate coverage?
- Check code style
- Run tests locally
- Test manually if UI changes
- Provide constructive feedback
- Approve or request changes
- Major: Breaking changes (2.0.0)
- Minor: New features (1.1.0)
- Patch: Bug fixes (1.0.1)
- Update version in
Info.plist - Update
CHANGELOG.md - Run full test suite
- Build release:
swift build -c release - Test on clean macOS install
- Create git tag:
git tag v1.0.0 - Push tag:
git push --tags
/// Detects the language of the given text.
///
/// Uses NLLanguageRecognizer for text with 3+ words,
/// falls back to character set heuristics for shorter text.
///
/// - Parameter text: The text to analyze
/// - Returns: Detected language or nil if uncertain
func detect(_ text: String) async -> Language?- Update
ARCHITECTURE.mdfor major changes - Document design decisions
- Explain trade-offs
- Open an issue for bugs
- Discussions for questions
- Pull requests for contributions
- Be respectful
- Be constructive
- Be inclusive
- Focus on the code, not the person
By contributing, you agree that your contributions will be licensed under the same license as the project.
Copyright © 2025 Chernistry. All rights reserved.