r/iOSProgramming • u/TheOfficialGojo • 6d ago
Discussion Hartbox boots Alpine Linux on an iPhone without JIT
I released Hartbox, an iPhone app that boots Alpine Linux in a Rust RISC-V emulator. It opens into a terminal and runs quite fast, in my testing it runs average of 1000+ MIPS
I tested it on my iPhone 17e and got `apk update` working. I used an AI assistant for parts of the code, debugging, and tests.
[GitHub repo and setup instructions](https://github.com/u6420771547-hash/hartbox)
[Download Hartbox.ipa](https://github.com/u6420771547-hash/hartbox/releases/download/v1.0.0/Hartbox.ipa)
The IPA is unsigned. I installed it through Xcode. If you try it, let me know how it runs on your phone. if you like it, a star on GitHub will be appreciated
1
u/ThalesMother9938 6d ago
Getting apk update to work on an iPhone with no JIT is the part that impressed me most, and 1000+ MIPS from an interpreter is more than I expected on iOS. How does networking work there? Do you run a user-mode stack inside the emulator, or pass guest traffic through to the app's own sockets?
1
u/InteractionWrong4029 6d ago
The no-JIT constraint quietly explains the rest of the design. On iOS you can't get writable-executable memory for unsigned code, so there's no translating to native and jumping into it - every guest instruction has to go through your dispatch loop. 1000+ MIPS with that overhead means the decode and dispatch cost is already down near the guest's own ALU work, which is the hard part.
If you want more out of it, the levers that usually pay off, roughly in that order: kill the big switch in favour of threaded/indirect dispatch or a precomputed decode cache, map guest RAM directly instead of bounds-checking every load/store, and batch syscalls so apk/apt isn't trapping into the host once per file stat.
One thing worth writing into the README: what happens to the guest filesystem when the app is backgrounded or the OS jetsams it, since that's the first thing anyone running apk will hit.