Local LLM-powered coding assistant for macOS using Apple's MLX framework
MLX Code is a native macOS application that brings powerful AI-assisted coding capabilities to your local machine using Apple's MLX machine learning framework. Think Claude Code or Cursor, but running entirely on your Mac with complete privacy and no cloud dependencies.
- 🤖 Local LLM Execution - Run code-focused models locally using Apple's MLX
- 🔧 Xcode Integration - Direct integration with Xcode projects (build, test, analyze)
- 💬 Chat Interface - Claude Code-style conversational interface
- 📁 File Operations - Read, write, edit, search files with AI assistance
- 🔒 Privacy First - All processing happens locally, no data leaves your machine
- ⚡ Apple Silicon Optimized - Leverages M-series chip capabilities via MLX
- 🛡️ Security Focused - Sandboxed execution, input validation, secure storage
- Language: Swift 5.9+
- UI Framework: SwiftUI
- ML Framework: MLX (via Python subprocess)
- Pattern: MVVM with Combine
- Deployment: macOS 14.0+ (Apple Silicon recommended)
MLX Code/
├── MLX Code/
│ ├── MLXCodeApp.swift # App entry point
│ ├── Models/
│ │ ├── Message.swift # Chat message model
│ │ ├── Conversation.swift # Conversation thread model
│ │ ├── AppSettings.swift # Settings manager
│ │ └── MLXModel.swift # MLX model configuration
│ ├── ViewModels/
│ │ └── ChatViewModel.swift # Main chat logic
│ ├── Views/
│ │ ├── ChatView.swift # Main chat interface
│ │ ├── MessageRowView.swift # Message display
│ │ ├── SettingsView.swift # Settings panel
│ │ └── ModelSelectorView.swift # Model picker
│ ├── Services/
│ │ ├── MLXService.swift # MLX model interface
│ │ ├── PythonService.swift # Python subprocess manager
│ │ ├── XcodeService.swift # Xcode integration
│ │ └── FileService.swift # File operations
│ ├── Utilities/
│ │ ├── SecureLogger.swift # Secure logging
│ │ └── SecurityUtils.swift # Security utilities
│ └── Resources/
│ └── Assets.xcassets/ # App icons and assets
├── MLX Code Tests/ # Unit tests
└── Documentation/ # Additional docs
- macOS 14.0+ (Sonoma or later)
- Apple Silicon Mac (M1/M2/M3/M4 recommended for best performance)
- Xcode 15.0+
- Python 3.10+ with MLX installed
- Command Line Tools (
xcode-select --install)
# Create virtual environment
python3 -m venv ~/mlx-env
# Activate environment
source ~/mlx-env/bin/activate
# Install MLX and dependencies
pip install mlx mlx-lm numpy transformers
# Verify installation
python -c "import mlx.core as mx; print(mx.__version__)"-
Clone/open project:
cd "/Volumes/Data/xcode/MLX Code" open "MLX Code.xcodeproj"
-
Configure Python path in app:
- Launch app
- Open Settings (⌘,)
- Set Python interpreter path (e.g.,
/Users/you/mlx-env/bin/python)
-
Build and run:
- Press ⌘R in Xcode
- Or: Product → Run
-
Select Model:
- Open Settings → Model tab
- Choose from pre-configured models (CodeLlama, Deepseek Coder, Qwen Coder)
- Or add custom MLX-compatible model
-
Configure Python:
- Settings → Advanced
- Set Python interpreter path
- Verify MLX installation
-
Start Chatting:
- Type your coding question or request
- MLX Code can read/write files, run builds, execute tests
File Operations:
"Read the contents of MyViewController.swift"
"Create a new file called NetworkManager.swift with URL session code"
"Find all TODO comments in the project"
"Replace all instances of 'oldMethod' with 'newMethod'"
Xcode Integration:
"Build the current project"
"Run unit tests and show me the results"
"Clean the build folder"
"Show me the current build settings"
Code Assistance:
"Refactor this function to use async/await"
"Add error handling to this network call"
"Write unit tests for this class"
"Explain what this code does"
- ⌘N - New conversation
- ⌘, - Settings
- ⌘R - Reload conversation
- ⌘K - Clear conversation
- ⌘⌃S - Toggle sidebar
-
Deepseek Coder 6.7B (Recommended)
- Best for code completion and generation
- Fast inference on M-series chips
- Supports 100+ programming languages
-
CodeLlama 13B
- Strong reasoning capabilities
- Excellent for refactoring and debugging
- Requires M2 Pro+ for good performance
-
Qwen Coder 7B
- Balanced performance/quality
- Good for general coding tasks
- Download MLX-compatible model
- Settings → Model → Add Custom Model
- Provide model path and configuration
- Load model and start using
Model Requirements:
- Must be MLX-compatible format
- Quantized models (4-bit/8-bit) recommended for speed
- Minimum 8GB unified memory for 7B models
- Theme (Light/Dark/System)
- Font size
- Auto-save conversations
- Keyboard shortcuts
- Model selection
- Temperature (0.0-2.0)
- Max tokens (128-8192)
- Top-p sampling
- Load/unload model
- Syntax highlighting
- Code block style
- Message spacing
- Python interpreter path
- MLX library path
- Debug logging
- Performance monitoring
- File operation permissions
-
Sandboxed Execution
- App runs in macOS sandbox
- Limited file system access
- User must approve directory access
-
Input Validation
- All user input sanitized
- Path traversal prevention
- Command injection protection
-
Secure Storage
- Settings encrypted with macOS Keychain
- No plaintext credential storage
- Automatic session cleanup
-
Privacy Protection
- All processing happens locally
- No network requests to external servers
- No telemetry or analytics
- Conversation data stays on your Mac
- ✅ Review generated code before executing
- ✅ Use file operation permissions to restrict access
- ✅ Keep Python environment updated
- ✅ Audit model sources before downloading
- ✅ Enable logging to track operations
- ❌ Don't store API keys or secrets in conversations
- ❌ Don't grant unrestricted file access
-
Project Management
- Open and parse .xcodeproj files
- Read build settings
- Analyze project structure
-
Build Operations
- Build project (
xcodebuild) - Clean build folder
- Archive for distribution
- Build project (
-
Testing
- Run unit tests
- Parse test results
- Show coverage reports
-
Code Analysis
- Swift syntax checking
- Compiler warnings/errors
- Static analysis
User: "Build the project and fix any warnings"
MLX Code:
1. Runs xcodebuild to build project
2. Parses compiler output for warnings
3. Identifies warning locations
4. Suggests fixes for each warning
5. Can automatically apply fixes with approval
Read:
- Read file contents
- Support for text files, code, JSON, XML
- Line number display
- Syntax highlighting
Write:
- Create new files
- Overwrite existing files (with confirmation)
- Automatic backup before modification
Edit:
- Find and replace
- Insert at line number
- Append to file
- Multi-file edits
Search:
- Glob pattern matching (
*.swift,**/*.m) - Grep with regex support
- Case-sensitive/insensitive search
- Context lines (before/after)
File operations require explicit user approval:
- First access to directory triggers permission request
- User grants access via macOS file picker
- Access persisted for future operations
- Can revoke access in Settings
# Open project
cd "/Volumes/Data/xcode/MLX Code"
open "MLX Code.xcodeproj"
# Build for testing
xcodebuild -project "MLX Code.xcodeproj" \
-scheme "MLX Code" \
-configuration Debug \
build
# Run tests
xcodebuild test -project "MLX Code.xcodeproj" \
-scheme "MLX Code" \
-destination 'platform=macOS'# All tests
xcodebuild test -project "MLX Code.xcodeproj" \
-scheme "MLX Code"
# Specific test
xcodebuild test -project "MLX Code.xcodeproj" \
-scheme "MLX Code" \
-only-testing:MLXCodeTests/ChatViewModelTests# Check for retain cycles and memory leaks
instruments -t Leaks -w "MLX Code"
instruments -t Allocations -w "MLX Code"Minimum:
- M1 Mac (8GB RAM)
- macOS 14.0
- 10GB free disk space
- 7B quantized model
Recommended:
- M2 Pro/Max or M3 (16GB+ RAM)
- macOS 14.0+
- 50GB free disk space
- Multiple models cached
- Use quantized models (4-bit/8-bit) for faster inference
- Close unused apps to free up memory
- Pre-load models at app launch for faster first response
- Enable MLX optimizations in Settings
- Monitor memory usage in Activity Monitor
| Model | Load Time | Tokens/sec | Memory |
|---|---|---|---|
| Deepseek 6.7B (4-bit) | ~8s | 45 | 6GB |
| CodeLlama 13B (4-bit) | ~15s | 28 | 10GB |
| Qwen 7B (8-bit) | ~10s | 38 | 8GB |
Symptoms: Error loading model, crashes on inference
Solutions:
- Verify Python path is correct (Settings → Advanced)
- Check MLX is installed:
pip list | grep mlx - Ensure model is MLX-compatible format
- Check available memory (Activity Monitor)
- Try smaller/quantized model
Symptoms: Can't build projects, missing xcodebuild
Solutions:
- Install Command Line Tools:
xcode-select --install - Set correct Xcode path:
sudo xcode-select -s /Applications/Xcode.app - Verify xcodebuild:
xcodebuild -version - Check Xcode project is valid
Symptoms: Permission denied, can't read/write files
Solutions:
- Grant file access when prompted
- Check Settings → Advanced → File Permissions
- Add directory to allowed list manually
- Verify file isn't locked or read-only
Symptoms: Long response times, high CPU usage
Solutions:
- Use smaller/quantized model
- Close background apps freeing memory
- Restart app to clear caches
- Check Python process isn't hanging (Activity Monitor)
- Enable performance monitoring to diagnose bottlenecks
- Follow Swift API Design Guidelines
- Use SwiftLint for formatting
- Document all public APIs
- Write unit tests for new features
- Check for memory leaks ([weak self])
- All closures use
[weak self]where appropriate - Delegates are marked
weak - No retain cycles in reactive chains
- Proper cleanup in
deinit - Tested with Instruments (Leaks tool)
- All input validated and sanitized
- No hardcoded secrets or credentials
- Error messages don't expose sensitive info
- File paths validated against traversal attacks
- Subprocess arguments properly escaped
- Logging sanitizes sensitive data
Internal/Local use. Not for distribution.
- MLX Framework: Apple ml-explore team
- UI Framework: SwiftUI
- Models: Various open-source projects (Deepseek, Meta, Alibaba)
Features:
- ✅ Chat-based interface with conversation management
- ✅ Local MLX model execution via Python subprocess
- ✅ Xcode project integration (build, test, analyze)
- ✅ File operations (Read, Write, Edit, Search)
- ✅ Pre-configured code models + custom model support
- ✅ Security features (sandboxing, validation, encryption)
- ✅ Settings management with persistence
- ✅ Comprehensive documentation
Test Coverage:
- Unit tests for all services
- Memory leak testing
- Security validation tests
- Integration tests for Xcode operations
Last Updated: 2025-11-18
Project Location: /Volumes/Data/xcode/MLX Code/
Status: ✅ Initial release ready for testing