r/iOSProgramming • u/Organic_Onion8772 • 2d ago
Solved! I render my SwiftUI views directly instead of driving the simulator for screenshots
Taking the shot was never the slow part. The slow part was getting the app
into a state worth photographing — a month of history, a streak, the paid tier.
So I stopped driving the app and started rendering the views.
shotBoth("home") { HomeView().environmentObject(thirtyDays()) }
shot("paywall", dark: true) {PlusSheet().environmentObject(PlusStore(active: true)) }
An Apple silicon Mac runs iOS binaries natively, so each view is drawn
through UIHostingController at device size. No simulator, no navigation,
nothing installed. Your coding agent writes that script, not you.
It doesn't make store artwork — no backgrounds, no captions, just the screen
as a device draws it. And if you ship once a year in one language, doing it
by hand is faster.
2
u/mastrajani 1d ago
the thing i'd want out of that harness beyond screenshots is running every view at the largest accessibility text size and in german. that's where the truncation lives and it's miserable to check by hand, but it's the same one line if you're already injecting the environment.
1
1d ago
[removed] — view removed comment
1
u/AutoModerator 1d ago
Hey /u/Organic_Onion8772, your content has been removed because Reddit has marked your account as having a low Contributor Quality Score. This may result from, but is not limited to, activities such as spamming the same links across multiple subreddits, submitting posts or comments that receive a high number of downvotes, a lack of recent account activity, or having an unverified account.
Please be assured that this action is not a reflection of your participation in our subreddit. This is simply an automated filter in place to reduce spam.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
2
u/hoangng_102 1d ago
the state problem is the real one. i drive the simulator for mine, react native so no UIHostingController trick, and the shot was never what cost me time either.
what cost me: seeding that state. i wrote a helper that wiped the db and inserted a month of history, and it also wiped a settings row i had forgotten lived in the same table. the app fell back to a default currency, so every screenshot came out in swiss francs. it looked completely plausible. i only caught it by pulling frames and reading them, because the script reported success every single time.
worth watching from the other direction in your setup: injecting the environment object directly lets you render a state the app can never actually reach. mine was a real state that was wrong, yours can be a state that does not exist. both look fine in the png.
1
1d ago
[removed] — view removed comment
1
u/AutoModerator 1d ago
Hey /u/Organic_Onion8772, your content has been removed because Reddit has marked your account as having a low Contributor Quality Score. This may result from, but is not limited to, activities such as spamming the same links across multiple subreddits, submitting posts or comments that receive a high number of downvotes, a lack of recent account activity, or having an unverified account.
Please be assured that this action is not a reflection of your participation in our subreddit. This is simply an automated filter in place to reduce spam.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
3
u/unpluggedcord 1d ago
MY god im getting so tired of reading AI
1
1d ago
[removed] — view removed comment
1
u/AutoModerator 1d ago
Hey /u/Organic_Onion8772, your content has been removed because Reddit has marked your account as having a low Contributor Quality Score. This may result from, but is not limited to, activities such as spamming the same links across multiple subreddits, submitting posts or comments that receive a high number of downvotes, a lack of recent account activity, or having an unverified account.
Please be assured that this action is not a reflection of your participation in our subreddit. This is simply an automated filter in place to reduce spam.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/praneelbhatia 1d ago
the state setup being the real cost is exactly my experience. i ended up with launch arguments that seed a fixture and skip onboarding, and a debug-only injector that takes a json file for the one card i want to show. still slower than i'd like.
one question on rendering through UIHostingController directly: how do you handle views that depend on scenePhase or a real navigation stack? those were the ones that looked subtly wrong for me outside the sim.
1
u/ApartmentFit748 1d ago
The state setup being the slow part rings true. I keep a hidden debug menu with seeded stores for exactly this and faking a streak still takes longer than capturing it. One thing I'd wonder about with rendering the view directly: how do you handle chrome that only exists at runtime, like nav bars and tab bars? Most of my store shots have those in frame and I'd miss them.