Menu

1 / 5

App Store Screenshots Without a Phone: Robolectric, a Fake Image Loader and a Headless Browser

DEV Community: ios·Nesim Razon·1 day ago
#A7Cnl48X
#devtoios#devto#dev#real#test
Reading 0:00
15s threshold

My iPhone apps share their screens with the Android versions, written once in Compose. App Store Connect wants screenshots at 1206x2622 pixels, and I work on a Windows laptop with no iPhone to spare for the job and a limited amount of cloud build minutes that I would rather spend on real builds. So I let unit tests draw the screens. This is how it works, what broke, and what these images honestly are.

The idea: let a unit test draw the screen

Robolectric runs Android code on the desktop JVM, and with native graphics mode it can draw Compose to a real bitmap. Roborazzi saves that bitmap as a PNG. So a screenshot becomes a test: set up the screen, click through to the state I want, capture the root node, done. No emulator, no phone, no build service.

One qualifier does the sizing: w402dp-h874dp-xxhdpi. That is a 402 by 874 dp screen at three pixels per dp, which gives exactly 1206x2622 pixels, the size App Store Connect asks for.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.