jacobx
jacobx on Hacker News
Hi HN! We're back with another post describing more detail about how we built Bitrig's interpreter for Swift in Swift, this time going into how we're converting the code into bytecode.
Posted by
jacobx on Tuesday September 16, 2025 @01:06PM
from the bitrig.app dept.
Yep! You can always export your code to take it to your computer.
We also have functionality in bitrig to build your app and send it to App Store Connect so you can deploy it on TestFlight.
We have a Mac app that we're beta testing with our existing subscribers. Is there a reason you want this on iPad instead of the Mac?
Yeah there was definitely some back and forth about it before we were eventually approved.
In a sense, this isn't very different from what React Native does (run interpreted code that calls out into native code), just with Swift instead of JavaScript. There used to be JavaScript-specific requirements in the guidelines, but that has been loosened since Swift Playgrounds was released. Now there are Python IDEs, Jupyter Notebooks, and other apps running arbitrary code in the App Store.
There's definitely a cost: everything is type-erased and there's a lot more indirection than there would be if the code was compiled. But you usually don't hit performance issues because most app code (especially in the UI) is just a thin layer calling into the OS frameworks. The framework code does the heavy lifting and is all compiled.
The places you can hit performance issues are things like when the app itself has a tight loop that's doing a lot of work.
I refer to Swift as a "compiled language" because no officially provided interpreter exists for it.
Bitrig runs Swift apps which are dynamically generated by an LLM on the iPhone, despite the iPhone strict security provisions (e.g. inability to write executable pages of memory). The way we do this is by parsing the generated Swift code and mapping that to the compiled calls to the libraries that come in the OS. It's pretty weird, but we think it's worth it to get the ability to immediately render the generated code on the phone.
That's not really been something we'd been considering, but yeah I think we probably could. We're primarily using the interpreter to render SwiftUI views, but it supports running arbitrary Swift expressions or statements.
I just pushed a change that should fix scrolling on Android browsers.
Yeah you could! The only caveat is that either the whole app, or at least the part of the app showing the view you want to replace, would have to be running via the interpreter.
We're very interested in using the interpreter to improve the Swift developer experience in more ways like that.
Thanks for letting us know! We're investigating now.
Thanks! Yes, it works just as well with UIKit. Fortunately Xcode can synthesize a .swiftinterface for Obj-C frameworks bridged into Swift, so we use that to generate a compiled interface for UIKit (and other Obj-C frameworks).
Hi HN! Since we launched Bitrig [1], we've gotten questions about how it's able to run dynamically generated Swift code. I wrote up this post to answer that. Let me know if you want to know more about any aspects of it.
1: https://news.ycombinator.com/item?id=45041185
Posted by
jacobx on Thursday September 04, 2025 @12:39PM
from the bitrig.app dept.
Thanks! Sure, feel free to email us: contact at our domain name.
Yes, we think that could be a really cool way to allow mocking up changes to parts of an app, especially for non-technical members of the team. We're not set up for that yet, but it's on our roadmap.
Thanks, we'll have to update the Contact Us link to work more generically. The Send Feedback link is when you're inside of a project, and you tap the ... in a circle button. It uploads your feedback and code directly to us, so is the best way for us to directly debug when we're not rendering your code correctly.
I'll take a look at camera access and see what's going wrong there.
Yeah this is an area we want to make a lot better. What we're currently thinking is giving the model a way to more explicitly call out that it is adding a call to something that needs an API key, which would add something to the UI to allow you to just paste in your key.
I think there's also work when need to do in the system prompt to guide the model away from all of the placeholder data (or at least so that when it adds it there's a better affordance to transform it to real data).
I think that’s a pretty good list. The main one I would add is “creators will want to make native Swift apps to have a better user experience”
Yeah that’s been my experience too. You can edit the Swift code directly in bitrig, though editing code on a phone is not the best experience. We’ve had a lot of requests for a Mac app. Stay tuned ;)
You can get a compiled build of your app from bitrig: go to Distribute App which will build your app on our server and then upload it to TestFlight for you (this requires a paid Apple Developer Account). This lets you install the compiled app on your Home Screen. You could also always export the code if you want to build it yourself.
There’s still a lot to do to make this work really great for the Swift ecosystem, and that’s where we have the most expertise, so that’s what we’ll be focused on for now.
That said, we think this same approach could work really well on Android, and it’d be interesting to expand there too.
Yeah we’d love to find a way to give away more in the free tier for hobbyist users and subsidize that with other things. The idea of us putting an ad in unpaid apps as another option is interesting.
We’ve gotten a lot of requests for WebKit, so we’ll try to add it soon.
If we hit issues we can try to pull in just a subset, but one nice thing about Swift is the frameworks have .swiftinterface files which list all the APIs in them, so we’ve generally been able to pull in whole frameworks at a time.
Thanks for trying, sorry you hit that issue!
Could you send us feedback from your project? (Go to the ... menu, then Send Feedback.) If you're not able to use the UI from within your project you can long-press on it from the main screen and choose Recovery Mode, and then enter the project with the interpreter disabled.
Thanks for letting us know, we'll get this fixed in other browsers (we've been just looking at it in Safari).
Totally agree, we have a lot of ideas for how to make the experience better.
We probably need to make this more discoverable, but if you keep swiping down on the prompt area, you can swipe it completely off screen and your app will be full screen (with a small movable floating button to exit).
I really like the idea of a platform for people sharing mini-apps! It would be great if people could make lightweight specialized apps for different niches and share them with less friction.
Yeah, I think that whole area of dynamically generating UI is really interesting. And having a Swift interpreter like we're using would unlock doing that with native UI components.
Our background is more in making developer tools, so bitrig was the first product we were excited about, but I think there's a lot of overlap with dynamic UI generation, and we'd love to explore that too.