c118996746
- SwiftUI macOS app with C++17 code analysis engine (ObjC++ bridge) - Agentic AI loop: LLM plans → tool calls → execution → feedback loop - 15 agent tools: file ops, terminal, git, xcode build, code intel - 7 persistent terminal tools with background session management - Chat sidebar with agent step rendering and auto-apply - NVIDIA NIM API integration (Llama 3.3 70B default) - OpenAI tool_calls format with prompt-based fallback - Code editor with syntax highlighting and multi-tab support - File tree, console view, terminal view - Git integration and workspace management
3.7 KiB
3.7 KiB
CxIDE — Build Guide
Prerequisites
| Tool | Minimum | Check |
|---|---|---|
| macOS | 14.0+ (Sonoma) | sw_vers -productVersion |
| Swift | 5.9+ | swift --version |
| Xcode | 15.0+ | xcodebuild -version |
| Clang++ | Apple clang 15+ | clang++ --version |
| Git | 2.x | git --version |
Quick Start
# First-time setup (validates toolchain, installs hooks)
./scripts/setup.sh
# Build (debug)
./scripts/build.sh
# Build (release)
./scripts/build.sh release
# Run tests
./scripts/test.sh
# Lint
./scripts/lint.sh
# Clean
./scripts/clean.sh
Build Targets
1. C++ CodeEngine (static library)
The C++ analysis engine compiles into libCxEngine.a:
# Manual compilation
clang++ -std=c++17 -O2 -c Core/CodeEngine.cpp -o .build/CodeEngine.o
clang++ -std=c++17 -O2 -fobjc-arc -c Core/SwiftEngineWrapper.mm \
-I Core -o .build/SwiftEngineWrapper.o
ar rcs .build/libCxEngine.a .build/CodeEngine.o .build/SwiftEngineWrapper.o
Source files:
Core/CodeEngine.hpp— C++ header (EngineConfig, Token, SymbolInfo, AnalysisReport)Core/CodeEngine.cpp— Full Swift tokenizer, symbol extraction, complexity metricsCore/SwiftEngineWrapper.h— Objective-C interface (40+ methods)Core/SwiftEngineWrapper.mm— ObjC++ bridge implementation
2. CxIDE App (Xcode / SwiftUI)
Open the project in Xcode and build normally, or use xcodebuild:
# If using an .xcodeproj
xcodebuild -scheme CxIDE -configuration Debug build
# SwiftUI previews
# Open any View file in Xcode and use the Canvas (⌥⌘P)
Key dependencies within the project:
- SwiftUI + AppKit (macOS window management)
- Foundation (file I/O, Process for code execution)
- The C++ engine is linked via the ObjC++ bridging header
3. CxSwiftAgent (SPM executable)
cd CxSwiftAgent
# Debug build
swift build
# Release build
swift build -c release
# Run tests
swift test
# Run the agent (HTTP mode)
.build/release/cx-swift-agent --port 3001 --workspace /path/to/project
# Run the agent (stdio mode — for MCP clients)
.build/release/cx-swift-agent --stdio
Docker build:
cd CxSwiftAgent
docker build -t cx-swift-agent .
docker run -p 3001:3001 -v /path/to/project:/workspace cx-swift-agent
Build Configurations
Debug (default)
-g -O0 -DDEBUGfor C++- Assertions enabled
- Full debug symbols
Release
-O2 -DNDEBUGfor C++- Optimizations enabled
- Static linking for agent binary
C++ Engine Configuration
The engine is configurable at runtime via EngineConfig / CppAnalysisConfig:
| Parameter | Default | Description |
|---|---|---|
maxLineLength |
120 | Warn on lines exceeding this |
maxNestingDepth |
5 | Maximum brace nesting depth |
maxFunctionLength |
50 | Lines before a function is "too long" |
minCommentRatio |
0.05 | Minimum comment-to-code ratio |
maxPrintStatements |
5 | Warn on excessive prints |
detectForceUnwraps |
true | Flag ! unwraps |
detectForceTry |
true | Flag try! |
detectForceCast |
true | Flag as! |
detectDuplicateLines |
true | Find repeated code |
detectTodoFixme |
true | Extract TODO/FIXME markers |
detectRetainCycles |
true | Warn on missing [weak self] |
Troubleshooting
| Problem | Solution |
|---|---|
swift not found |
Install Xcode or download Swift from swift.org |
clang++ not found |
Run xcode-select --install |
| C++ compilation errors | Ensure C++17 support: clang++ -std=c++17 |
| ObjC++ bridge errors | Check -fobjc-arc flag and bridging header path |
| Agent build fails | Verify Package.swift targets macOS 14+ |
| Tests timeout | CxSwiftAgent tests need write access to /tmp |