SwiftUI WebView
In the WWDC video, they demonstrated how to track the navigation events. The code in the video does not work - it doesn’t even compile. But after some trial and error, I worked out how to track these events.
[…]
If you want your
WebView
to load custom pages, create a custom scheme. In my Man Reader app, I use a custom scheme to load HTML versions of man pages, so I decided to try something similar here.[…]
In macOS Tahoe 26 beta 7 and Xcode 26 beta 6, this external navigation prints what appears to be a crash log in the console, but the app does not crash.
[…]
I have included the
replaceDisabled(true)
modifier but it doesn’t work in aWebView
. The modifier doesn’t stop the replace interface from appearing, but replacing doesn’t actually work[…][…]
At first, I assumed that
page.load()
required aURL
or aURLRequest
, but then I realized that I could also ask it to load aWebPage.BackForwardList.Item
directly. […] I had a problem with the back and forward menus which made me think that the history was not updating correctly. After temporarily re-purposing the refresh button to list the history items, I worked out that history list was correct but the menus were not being updated when the list changed.
Previously:
2 Comments RSS · Twitter · Mastodon
All that work, that messy looking code, all the gotchas, just to avoid using WKWebView? 🤷♂️ I really don’t understand this world anymore. Or maybe it’s just grifting for clicks, much like the rest of the Swiftfluencer crowd.
I remember a time when articles actually showed how to do interesting stuff, not take your existing code that works and is readable, and turn it into a n unreadable Swift[UI] slop. These kind of articles used to just be called Apple Documentstion.
> In the WWDC video, they demonstrated how to track the navigation events. The code in the video does not work - it doesn’t even compile. But after some trial and error, I worked out how to track these events.
Wasn’t there another wwdc video lingering for a few years with non working Swifty code? Was it efficiency awaits background tasks something something?
Apple presenting code that doesn’t even compile at recent WWDC…if that isn’t enough to scare you away from these APIs when stable alternatives exist…you may need help. You might just be a Swift sicko masochist.
I mean what the fuck not a runtime error, it doesn't compile?