AI Code Assistant (Code Assist) for Mobile App

TRUETECH is engaged in the development, support and maintenance of iOS, Android, PWA mobile applications. We have extensive experience and expertise in publishing mobile applications in popular markets like Google Play, App Store, Amazon, AppGallery and others.
Development and support of all types of mobile applications:
Information and entertainment mobile applications
News apps, games, reference guides, online catalogs, weather apps, fitness and health apps, travel apps, educational apps, social networks and messengers, quizzes, blogs and podcasts, forums, aggregators
E-commerce mobile applications
Online stores, B2B apps, marketplaces, online exchanges, cashback services, exchanges, dropshipping platforms, loyalty programs, food and goods delivery, payment systems.
Business process management mobile applications
CRM systems, ERP systems, project management, sales team tools, financial management, production management, logistics and delivery management, HR management, data monitoring systems
Electronic services mobile applications
Classified ads platforms, online schools, online cinemas, electronic service platforms, cashback platforms, video hosting, thematic portals, online booking and scheduling platforms, online trading platforms

These are just some of the types of mobile applications we work with, and each of them may have its own specific features and functionality, tailored to the specific needs and goals of the client.

Showing 1 of 1 servicesAll 1735 services
AI Code Assistant (Code Assist) for Mobile App
Complex
~1-2 weeks
FAQ
Our competencies:
Development stages
Latest works
  • image_mobile-applications_feedme_467_0.webp
    Development of a mobile application for FEEDME
    760
  • image_mobile-applications_xoomer_471_0.webp
    Development of a mobile application for XOOMER
    649
  • image_mobile-applications_rhl_428_0.webp
    Development of a mobile application for RHL
    1067
  • image_mobile-applications_zippy_411_0.webp
    Development of a mobile application for ZIPPY
    947
  • image_mobile-applications_affhome_429_0.webp
    Development of a mobile application for Affhome
    884
  • image_mobile-applications_flavors_409_0.webp
    Development of a mobile application for the FLAVORS company
    452

Implementing AI-Powered Code Assistant in Mobile Applications

Mobile Code Assist isn't just "chat with GPT about code." It's an editor with syntax highlighting, autocomplete, code explanation, and ability to execute requests in the context of open file. Target audience: mobile IDEs, educational platforms, code review tools on phone.

Code editor: basic requirements

Standard UITextView/EditText doesn't work for code. Need syntax highlighting, monospace font, horizontal scroll, correct Tab/indent handling.

iOS: Runestone (open-source, Tree-sitter grammars) or Sourceful. Android: CodeEditor from Rosemoe or embed WebView with CodeMirror/Monaco.

// iOS with Runestone
import Runestone

let textView = TextView()
textView.theme = OneDarkTheme()
textView.language = TreeSitterLanguage.swift  // or python, js, etc.
textView.font = UIFont.monospacedSystemFont(ofSize: 14, weight: .regular)
textView.showLineNumbers = true
textView.isLineWrappingEnabled = false  // horizontal scroll for code

Tree-sitter grammars available for 50+ languages. Highlighting incremental—on line change, only changed portion reparses, not whole file. Critical for large files.

AI part: contextual requests

Code Assist must understand context: open language, code around cursor, selected text. All goes in prompt.

struct CodeAssistRequest {
    let userQuestion: String
    let codeContext: CodeContext
}

struct CodeContext {
    let language: String
    let fullCode: String       // entire file, if < 3000 tokens
    let selectionStart: Int
    let selectionEnd: Int
    let cursorLine: Int

    var selectedCode: String {
        String(fullCode.utf16.prefix(selectionEnd).dropFirst(selectionStart)) ?? ""
    }

    var surroundingContext: String {
        // 50 lines around cursor
        let lines = fullCode.components(separatedBy: "\n")
        let from = max(0, cursorLine - 25)
        let to = min(lines.count, cursorLine + 25)
        return lines[from..<to].joined(separator: "\n")
    }
}

func buildMessages(for request: CodeAssistRequest) -> [ChatMessage] {
    let systemPrompt = """
    You are a \(request.codeContext.language) expert. Answer questions about the provided code.
    When suggesting code changes, output only the changed code block.
    Language: \(request.codeContext.language)
    """

    let userMessage = """
    Code context:
    ```\(request.codeContext.language)
    \(request.codeContext.surroundingContext)
    ```
    \(request.codeContext.selectedCode.isEmpty ? "" : "Selected code:\n```\n\(request.codeContext.selectedCode)\n```\n")
    Question: \(request.userQuestion)
    """

    return [
        ChatMessage(role: "system", content: systemPrompt),
        ChatMessage(role: "user", content: userMessage)
    ]
}

Parsing code blocks from response

LLM returns text with markdown code blocks. Parse and offer to apply.

// Android
fun parseCodeBlocks(response: String): List<CodeBlock> {
    val regex = Regex("```(\\w+)?\\n([\\s\\S]*?)```")
    return regex.findAll(response).map { match ->
        CodeBlock(
            language = match.groupValues[1].ifEmpty { "plaintext" },
            code = match.groupValues[2].trimEnd()
        )
    }.toList()
}

data class CodeBlock(val language: String, val code: String)

UI: "Apply" button next to each code block. Apply via replaceSelection() or insert at specific file position.

Chat history and multi-turn requests

One code question rarely suffices. Need dialog history—but not all, else context overflows.

Strategy: store last 6 question/answer pairs + original system prompt with file context. On file change, update system prompt—recreate history.

Important nuance: code blocks in LLM responses consume many tokens. When storing history, replace large code blocks with [code block replaced, N lines]—preserves dialog context without inflating request.

On-device models for code

For products where code privacy matters: Ollama with codellama:7b or qwen2.5-coder:7b on user's server. Full on-device on mobile phone still unrealistic for code—minimum working model needs ~4 GB RAM.

iOS 18+ Apple Intelligence provides on-device LLM via Foundation Models, but limited context and no code specialization. Not alternative for code assist.

Timeline estimates

Editor with highlighting + basic Q&A chat—1 week. Full Code Assist with file context, code block parsing, apply changes, chat history—3–4 weeks.