admaDIC App Development & IT Solutions

Local LLM based AI-Assisted Code Review Comments in Xcode - Part 1

by Annett Schwarze | 2026-04-19

In this series an Xcode Source Editor Extension is built, that analyzes Swift code using a locally running language model (via llama.cpp) and inserting generated review comments directly into the source code as inline annotations are covered.

Sample AI Review

In the first part a locally running LLM is installed.

Prerequisites

Setting Up the Local LLM

Install llama.cpp

Open a terminal and change to a directory where you want to save llama.cpp. Run the commands listed below one by one:

        
# Clone the llama.cpp repository
git clone https://github.com/ggerganov/llama.cpp.git
cd llama.cpp

# Prepare the build directory
mkdir build
cd build

# Build with Metal acceleration for Apple Silicon
cmake .. -DGGML_METAL=ON && cmake --build . --config Release

# Prepare for downloading models
cd ..
mkdir -p models

# Download a coding-focused model (CodeLlama 7B)
# This is optimized for code analysis and fits in 8GB RAM
curl -L -o models/codellama-7b-instruct.Q4_K_M.gguf \
  https://huggingface.co/TheBloke/CodeLlama-7B-Instruct-GGUF/resolve/main/codellama-7b-instruct.Q4_K_M.gguf
    

Test the Model

Run the following command to test that the model works:

        
    ./build/bin/llama-cli -m models/codellama-7b-instruct.Q4_K_M.gguf \
  -p "Review this Swift code for issues: func getData() { let x = 0 / 0 }" \
  -n 128
    

▶ Play video in full resolution

Recording Local LLM Test

This is an example output from the model performing the prompt "Review this Swift code for issues: func getData() { let x = 0 / 0 }":

        
▄▄ ▄▄
██ ██
██ ██  ▀▀█▄ ███▄███▄  ▀▀█▄    ▄████ ████▄ ████▄
██ ██ ▄█▀██ ██ ██ ██ ▄█▀██    ██    ██ ██ ██ ██
██ ██ ▀█▄██ ██ ██ ██ ▀█▄██ ██ ▀████ ████▀ ████▀
                                    ██    ██
                                    ▀▀    ▀▀

build      : b8586-64ac9ab66
model      : codellama-7b-instruct.Q4_K_M.gguf
modalities : text

available commands:
  /exit or Ctrl+C     stop or exit
  /regen              regenerate the last response
  /clear              clear the chat history
  /read <file>        add a text file
  /glob <pattern>     add text files using globbing pattern


> Review this Swift code for issues: func getData() { let x = 0 / 0 }

This Swift code is illegal because division by zero is not allowed.
To fix this error, you should change the value of x to a valid number.
func getData() { let x = 1 / 1 }
<|im_end|>


[ Prompt: 131.5 t/s | Generation: 26.3 t/s ]

>
    

What's next

With the local model now set up and ready for use, the next part will focus on integrating it into your development workflow. It will cover how to implement an Xcode Source Editor Extension that leverages the model to analyze Swift code and provide inline review feedback directly within the editor.

 

www.admadic.de | webmaster@admadic.de | Legal Notice and Trademarks | Privacy
© 2005-2007 - admaDIC | All Rights Reserved
All other trademarks and/or registered trademarks are the property of their respective owners
Last Change: Sun Apr 19 07:48:12 2026 GMT