Local LLMs for Mobile Development
With the launch of Xcode 26, a new era of AI-assisted development has opened for iOS developers. The ability to run large language models (LLMs) locally offers privacy, full control, and independence from internet connections. In this article, I’ll share my practical experience with different tools and configurations to maximize productivity in mobile development.
Why Choose Local LLMs?
Running LLMs locally brings several significant advantages:
- Privacy: Your code never leaves your environment
- Speed: No network latency
- Availability: Works offline
- Control: You choose exactly which model to use
- Cost: No usage fees after initial setup
The main challenge is intensive RAM and GPU usage, especially with larger models. The good news is that there are strategies to optimize this aspect.
Setting Up Ollama: Your Gateway
Ollama is currently the most versatile tool for running LLMs locally. Its installation is simple on any platform:
Installation
- On macOS:
brew install ollama- Other platforms: Visit ollama.com for direct download
Essential Commands
# Start the service
ollama serve
# Run a model
ollama run llama3.2Ollama offers a vast library of optimized models. Explore the available options at ollama.com/search to find the model that best fits your needs and hardware resources.
Distributing the Load: Multi-Machine Configuration
A smart strategy to work around hardware limitations is to distribute processing. If you have a second computer with a dedicated GPU or Apple Silicon (Mx) chips, you can configure it as an AI server.
Remote Server Configuration
- Configure the OLLAMA_HOST environment variable on the computer that will serve as the server
- Point your IDE to the server’s IP and port (example:
http://192.168.0.110:11434)
For a detailed tutorial on OLLAMA_HOST configuration, see: Kubert Assistant Lite — Ollama Setup
⚠️ Important for Windows Users
On Windows, make sure to enable port 11434 in the Firewall through advanced settings to allow remote connections.
Creating a Python Proxy for Maximum Compatibility
Some tools require Ollama to be running on the same machine. To work around this limitation, I found a Python script online that acts as a proxy, redirecting local connections to a remote server:
import socket
import threading
LOCAL_HOST = '127.0.0.1'
LOCAL_PORT = 11434
REMOTE_HOST = '192.168.0.110'
REMOTE_PORT = 11434
def handle_client(client_socket):
try:
# Connect to remote server
remote_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
remote_socket.connect((REMOTE_HOST, REMOTE_PORT))
# Function to transfer data between client and remote server
def forward(src, dst):
while True:
data = src.recv(4096)
if not data:
break
dst.sendall(data)
# Threads to transfer data in both directions
client_thread = threading.Thread(target=forward, args=(client_socket, remote_socket))
server_thread = threading.Thread(target=forward, args=(remote_socket, client_socket))
client_thread.start()
server_thread.start()
client_thread.join()
server_thread.join()
except Exception as e:
print(f"[ERROR] {e}")
finally:
client_socket.close()
remote_socket.close()
def start_proxy():
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind((LOCAL_HOST, LOCAL_PORT))
server.listen(5)
print(f"Proxy listening on {LOCAL_HOST}:{LOCAL_PORT}...")
try:
while True:
client_sock, addr = server.accept()
print(f"Connection received from {addr}")
threading.Thread(target=handle_client, args=(client_sock,)).start()
except KeyboardInterrupt:
print("Shutting down proxy...")
finally:
server.close()
if __name__ == "__main__":
start_proxy()After running the proxy, test connectivity with ollama list to verify it's working correctly.
Compatible Development Tools
Xcode 26
The integrated Swift Code Assistant offers native support for local LLMs, providing a more fluid and intelligent development experience.
Visual Studio Code
Two extensions stand out for Ollama integration:
- Continue: Advanced code assistant with support for multiple models
Simplified Alternative: LM Studio
For developers who prefer an all-in-one solution, LM Studio offers an intuitive graphical interface with complete support for:
- Interactive chat
- Code assistance
- MCP (Model Context Protocol)
- Local execution without complex configurations
🚨 Works only on the same machine
Does not allow using the Python proxy or configuring an external API to consume LLMs.
Performance and Optimization Considerations
Model Selection
- Smaller models consume less RAM but may have limited capabilities
- Test different sizes to find the ideal balance between performance and quality
- Consider code-specialized models for development
Hardware Resources
- RAM: Minimum 8GB, recommended 16GB+ for larger models
- GPU: Significantly accelerates processing (NVIDIA CUDA or Apple Silicon)
- Storage: Models can occupy several GB and need an SSD with high read rates
Conclusion
The integration of local LLMs into the mobile development workflow represents a significant leap in productivity and autonomy. With the tools and configurations presented in this article, you can:
- Maintain total control over your data and code
- Work offline without external dependencies
- Completely customize your AI-assisted development experience
Experiment with the different approaches presented and find the combination that best fits your workflow. The future of mobile development is already here, and it runs locally on your machine.
