# iOS Runtime Logging - Cursor Rules

This project includes a plug-and-play iOS runtime logging system.

## Automatic Error Fixing

**IMPORTANT: When build errors are detected:**

1. **Automatically check** `.ios-runtime-logs/.cursor_auto_fix.md` for error details
2. **Analyze the errors** and identify root causes
3. **Automatically fix the code** in the relevant source files
4. **Verify fixes** are correct and don't break existing functionality
5. **No user interaction required** - fix errors automatically

When you see `.cursor_auto_fix.md`, `.cursor_auto_fix_trigger.md`, or `.cursor_build_errors_ready` files, immediately:
- Read the error file (`.ios-runtime-logs/.cursor_auto_fix.md`)
- Analyze all errors
- Fix all errors automatically in the relevant source files
- Update the code files as needed
- Ensure the project builds successfully
- No user interaction required - fix errors automatically

**CRITICAL: If you see `.cursor_auto_fix_trigger.md` in the project root, immediately read `.ios-runtime-logs/.cursor_auto_fix.md` and fix all errors automatically.**

## Available Actions

Use these commands via Cursor's command palette (Cmd+Shift+P):

- `ios-runtime-logging:install` - One-time setup and installation
- `ios-runtime-logging:start` - Start streaming runtime logs
- `ios-runtime-logging:stop` - Stop logging
- `ios-runtime-logging:inspect` - View latest logs for AI analysis
- `ios-runtime-logging:status` - Check logging status
- `ios-runtime-logging:capture-build-errors` - Capture errors and trigger auto-fix

## Quick Start

1. Run `ios-runtime-logging:install` to set up the project
2. Add `RuntimeLogger.swift` from `.ios-logging-helper/` to your Xcode project
3. Import and use `RuntimeLogger` in your code
4. Run `ios-runtime-logging:start` when developing
5. Use `ios-runtime-logging:inspect` to view logs

## Log Location

Logs are stored in `.ios-runtime-logs/` directory. This directory is automatically excluded from git.

## AI Analysis

You can ask Cursor AI to analyze the logs:
- "What errors occurred in the latest log?"
- "Analyze performance issues"
- "Show me all user interactions"
- "What network requests were made?"

Logs are automatically formatted for easy AI analysis.

## Auto-Fix Behavior

When build errors are detected:
- Errors are automatically sent to Cursor AI
- Fix instructions are created in `.ios-runtime-logs/.cursor_auto_fix.md`
- Cursor AI should automatically read and fix errors
- No manual intervention needed

