Flutter on watchOS: AI-Designed Architecture Test
Краткое содержание
Pixel shares a Flutter-on-watchOS experiment that streams frames over a local WebSocket into a SwiftUI Canvas, with taps routed back and pixel output verified in CI. It maps watchOS SDK blockers and invites Apple Watch owners to test JIT, networking, memory, and decode speed—important groundwork for possible wearable support, though real-device feasibility remains unproven.
DEV Community
Stress-Testing an AI-Designed Architecture for Flutter on watchOS (Experiment)
TL;DR Prototype for Apple Watch hot reload, in the Simulator. Flutter frames stream over a local WebSocket into a SwiftUI Canvas, and taps travel back, with a first frame in a few hundred milliseconds in CI. On a real watch, Apple's TN3135 says this networking is blocked, so the real-device version is the open question. The Flutter engine's embedder.h interface can run Dart in a watchOS Simulator process. A retagged macOS debug engine rendered glyphs and colors, handled a tap and a synthetic scroll, and every pixel was checked in CI. It's a wiring experiment that never ships. A reproducible map of what blocks Flutter on watchOS. Metal.h, CAMetalLayer, UIView and fork() don't compile against the watchOS SDK, while SpriteKit, CoreGraphics, CoreText and the Crown API do. 22 of the desktop embedder's 673 imported symbols are missing, 21 of them Metal-related. A hardware probe for whoever picks this up. A small open watchOS app and Mac server print one paste-ready result block covering JIT, networking, memory and decode speed. Anyone with an Apple Watch and a Mac can run it and answer the questions CI can't. I don't own the hardware, so this is where my part of the work stops. Built and verified with no Mac and no watch. Every result comes from GitHub's macOS runners, with AI assistance disclosed in the repo. Not proven: anything on a physical watch, an AOT or source-built engine, battery, memory limits, and App Review acceptance. For the longest time, I have always wanted to see Flutter on watchOS, so that one day I could do cross-platform development between watchOS and Wear OS. In a Flutter survey, I submitted this request, but it was never part of their roadmap. So, I did a lot of brainstorming on how to achieve it and build a proof of concept to demonstrate, hoping to eventually see first-party support for wearables. On the Wear OS side, I wasn't too worried since there are a bunch of packages that allow you to work with it, though it would still be interesting to see official tooling for Wear OS. As for watchOS, the main reasons were that no one had built the engine embedder for WatchKit, and the tooling and plugin ecosystem didn’t support the platform. However, I didn't stop there, even though I have never owned an Apple Watch or written a single line of Swift. As AI was getting better, I began to brainstorm with Gemini to eventually bring this to light while diligently learning prompt engineering to get the answers I sought. Given that AI was trained on data available on the internet, I kept seeing the same response: that it was nearly impossible to achieve because of Apple's ecosystem and device limitations. Then I did the same with Claude. I did this repeatedly to see what the AI could come up with. The core problems I faced with watchOS were the lack of Metal, no UIKit, a 30 MB memory limit, no JIT for hot reload, and no Dart VM at runtime. I used Gemini and Claude as thinking partners to work through whether it was even architecturally possible. Then I had an idea: I asked Claude to create a specification document of what we discussed. I used this document to ask Gemini for its thoughts on the plan. Gemini proposed some changes, which I then validated with Claude to see if they were plausible, while also using my knowledge as a programmer to see if it made sense. For each new idea or proposed fix I received from Claude, I recreated the document with AI, adding a changelog and incrementing its version along with new updates. I've managed to find clues and solutions to work around watchOS's strict ecosystem. What I came up with is a two-mode architecture. In development, Flutter runs on your Mac and streams frames to the watch over WebSockets for hot reload. In production, the Flutter engine runs on the watch itself through the embedder API. Both modes draw using SwiftUI's Canvas. An interesting aspect of this research branch is making each draw call low-allocation by writing raw bytes into shared native memory that S...

Powered by Readybot.io