Large Language Model Selection for Test-Driven Prompt Android iOS Development
TL;DR Highlight
Adding tests to prompts raised mobile code generation accuracy by 2.22pp on average.
Who Should Read
A mobile developer using LLMs for Android (Java) or iOS (Swift) code generation who needs to pick the right model.
Core Mechanics
- Tests in the prompt help a little
- Test-driven prompting (TDP, giving test cases along with the task) improved average accuracy by 2.22pp over the base prompt.
- The result was statistically significant, with an effect size of d = 0.3974.
- Mobile lags well behind Python
- Python code generation accuracy was 86.90%–91.30%.
- Mobile (Java, Swift) was 66.85%–88.87%.
- The gap held regardless of model size or type.
- 8,704 evaluations were run
- 544 tasks from HumanEval and MBPP were evaluated on Android (Java) and iOS (Swift).
- GPT-4o, GPT-4o-mini, Qwen 14B and Qwen 32B were compared across two prompting strategies.
- A decision tree guides model choice
- It branches on first-attempt correctness, budget, and self-hosting needs.
- It was validated on three industry-relevant use cases.
- Patterns differ by platform
- The paper analyzed platform-specific patterns and built them into the tree.
- It frames this as groundwork for platform-specific optimization.
Evidence
- TDP averaged +2.22pp
- Accuracy gain over the baseline prompt.
- 95% CI [1.22–3.23pp], p < 0.001, d = 0.3974.
- Mobile at 66.85%–88.87%
- Android and iOS code generation accuracy range on HumanEval and MBPP.
- Python-based generation scored 86.90%–91.30%.
- 8,704 evaluations total
- 544 tasks, 4 LLMs, 2 prompting strategies, and 2 metrics (accuracy, remediation accuracy).
How to Apply
- Add tests to your current mobile prompts
- Today, add 3–5 input/output test cases to your Swift or Java function generation prompt.
- Run the same tasks without tests and compare pass rates.
- Frame model choice around three criteria
- Tabulate first-attempt correctness, budget, and self-hosting needs.
- Run candidates (GPT-4o, GPT-4o-mini, Qwen) on your own tasks to compare.
- Verify mobile output more strictly than Python
- Always run unit tests in CI on generated Java and Swift code.
- Do not carry over Python-level accuracy expectations.
Try It
# Paste into Claude or ChatGPT as is (simplified version of the paper's method: test-driven prompting)
Write a Swift function that meets the requirements below.
[Requirements]
{{function description}}
[Function signature]
{{signature}}
[Tests that must pass]
{{3-5 test cases}}
Rules:
1. Write code that passes all the tests above.
2. After writing, mentally run each test and check the result.
3. If any test seems likely to fail, fix the code and output only the final version.Terminology
Related Papers
Why Do LLMs Help with Scientific Misconduct Requests and What to Do About It?: Increasing the Trustworthiness of AI for Science
Adding an intention-analysis system prompt raised refusal of misconduct requests from 58% to 87%.
How Specification Explicitness Shapes Failure in LLM-Generated Code
Spelling out invariants, edge cases and constraints cut hidden-test failures in LLM code by 47.2%.
Same Task, Different Statement: When and How Reformulation Helps LLM Problem Solving
Rewriting problem statements to fit their type raises LLM accuracy, but blind rewriting hurts.
Show HN: STE80 Humanizer – de-AI text by writing 80% of the way to ASD-STE100
A skill strips 26 AI tells and rewrites text in short ASD-STE100-style sentences
Character-Name Concentration in LLM Fiction: Measuring Displacement and Mitigating Repetition
Drafting name candidates and filtering by frequency cut LLM character-name repetition by 95%
LLM Voice
Martin Fowler: LLM-drafted prose keeps an uncanny tone even after human editing.
The Instruction Tax on Factual Recall: Base Models Can Beat Their Instruction-Tuned Counterparts
Few-shot completion with repeated sampling on a base model beat chat: F1 0.684 vs 0.568
AI is a tool and using it well takes skill
A rebuttal to Hickey: LLMs are tools, and skill in directing and checking them decides the outcome
Original Abstract (Expand)
Large language model (LLM) code generation research predominantly focuses on Python, with test-driven prompt engineering exclusively targeting this language. This study presents a comprehensive LLM selection framework for mobile development through rigorous empirical analysis. We conducted 8,704 evaluations across 544 programming tasks (HumanEval and MBPP datasets) on Android (Java) and iOS (Swift) platforms using four state-of-the-art LLMs (GPT-4o, GPT-4o-mini, Qwen 14B, and Qwen 32B), two prompting strategies (base and test-driven), and two metrics (accuracy and remediation accuracy). Systematic analysis of platform-specific patterns yielded a decision tree incorporating first-attempt correctness, budget constraints, and self-hosting requirements, validated through three industry-relevant use cases. Results show test-driven prompting (TDP) achieves a +2.22 pp average accuracy improvement over baseline (95% CI [1.22–3.23 pp], p < 0.001, d = 0.3974). However, LLMs consistently underperform in mobile development (66.85%–88.87%) compared to Pythonbased code generation (86.90%–91.30%) regardless of model size or type. This framework establishes groundwork for platform-specific optimizations while providing practitioners with actionable guidance for model selection in mobile development contexts.