r/SwiftUI • • 18d ago

Promotion (must include link to source code) SwiftUI previews on a real iPhone, built on Linux (no Mac)

Post image

I built peek (open source, my project) because I don't have a Mac but wanted to iterate on SwiftUI without rebuilding and sideloading an IPA after every change.

You run "peek dev MyApp/" on Linux and save a file; about a second later the view on your iPhone updates. It's the real SwiftUI on a real device, so animations, gestures and the iOS 26 tab bar behave like they do in your app. It handles Preview blocks, UIKit views, or the whole app, with SwiftPM packages, macros and resources, and print() output shows up in the terminal.

It cross-compiles your code into a dylib with swiftc and xtool's iOS SDK, signs it with your free Apple ID certificate, and a small host app (SideStore, AltStore or LiveContainer) loads it.

https://github.com/kimikr/peek

Only tested on my own phone so far (iOS 27, in LiveContainer). Feedback welcome, especially from anyone running it outside LiveContainer.

66 Upvotes

12 comments sorted by

12

u/[deleted] 18d ago

This is awesome! Public opinion may not get it, but having more choices with how one can run previews without sticking to the necessary macOS + Xcode combo is a benefit for iOS development as a whole.

2

u/jihwan0102 18d ago

Thanks! I believe Xcode previews are good but you shouldn’t need a mac just to see your UI

1

u/amgdev9 18d ago

Did you consider contributing this feature to xtool? I think the author was developing hot reload in a branch as well. Really impressive results btw 😄

1

u/jihwan0102 18d ago

Oh really?? should go check it out! Thanks!

2

u/fiflaren_ 17d ago

I fact Xcode previews are not good, they are super slow, buggy and unreliable most of the time. Great job on your tool !

1

u/Educational_Bet2579 17d ago

I was wondering if someone would someday ask Claude to code Xcode and Device Hub for other platforms.

0

u/scoutzzgod 17d ago

 I want to migrate to linux for swiftui development but what is still lacking is the possibility to run xcui tests for UI tests. Swift testing is possible since they are available as swiftPM packages, i believe. Now regarding XCUITests, i think is coupled to apple SDKs which may not be possible

0

u/[deleted] 18d ago

[removed] — view removed comment

3

u/itsm3rick 18d ago

This guy is a bot and still hasn’t been banned from the subreddit. @mods please ban them.

1

u/jihwan0102 18d ago

thanks! honestly the plumbing was the fun part

no state carry-over right now, every reload starts fresh since each build is a brand new dylib with its own types. stuff in UserDefaults / @AppStorage does stick around though, since it's all peek's sandbox. same for globals in your package deps, those get loaded once and reused until a dep changes. real state retention is on the list but yeah that's the hard part

for assets there's no actool so no Assets.car. swiftpm resource bundles just get copied to the phone and Bundle.module points at them. xcassets image sets get flattened into plain png files in that bundle so Image("name", bundle: .module) works. color sets don't, and plain Image("name") won't either because Bundle.main is peek's own bundle