Show newer

@jasonhowlin indeed an opaque type should preserve type information, but it appears Xcode Previews for whatever reason discards it. 🤷‍♂️

@helge @groue You're right that this is a Swift Package. Specifically, running from an Xcode Preview. Linking and running from simulator yields the 3 identical results. How curious!

@helge @groue view extensions for modifiers are super common yes, but I have not seen their type erasure talked about before mastodon.notsobig.co/@phill/11

Edit: Macro is a neat idea, though.

@mattiem yes quite surprising! Presumably AnyView is introduced by the runtime?

I thought it made sense, but now I’m not sure it does. 😅

@cvieiragoebel@berlin.social thank you Christopher!

I'm a little embarrassed to admit, but I had been blissfully unaware that View extensions are type erasing.

That means if you have an extension for using your ViewModifier in a more ergonomic way, it'll be erased to AnyView unless you explicitly mark it as @inlinable.

gist.github.com/phillipcaudell

Edit: Perhaps this is just a quirk of Xcode Previews: mastodon.notsobig.co/@phill/11

@shauny that's definitely an option! It's just iPad is frustratingly close to finished; these last little things are letting it down.

@simonnickel Yeh it's 100% caused by switching on the size class. The irony is I'm only doing so because of a separate issue with NavigationSplitView (mastodon.notsobig.co/@phill/11).

Your problem looks similar though. I've had some mild success now by tying the lifetime of the State directly to the NavigationStack. Both get destroyed together (keeping the Stack happy). The State can then be restored through some other mechanism (like a Binding) gist.github.com/phillipcaudell

NavigationStack loses its navigation bar on iPad when returning from the background, making it impossible to go back or do anything. iOS 16 and 17.

FB13120953

gist.github.com/phillipcaudell

@matt1corey the scenePhase reports .background, but yes! A little confusing at first, but I suppose it makes some sense.

Something that tripped me up recently was not understanding how .onAppear { } behaves on iPad.

It gets called multiple times, even though the view is not visible.

Why? Logging reveals the size class is also changing, so presumably iOS is taking snapshots for the app switcher.

If like me you rely onAppear to denote a user has seen something (say, Mark as Read), you'll need to check the scenePhase first.

Here's a gist: gist.github.com/phillipcaudell

@bdewey @mattiem NavigationSplitView has a number of issues related to the column’s view identity changing. Group has no affect on layout whereas ZStack does, so I imagine that makes a difference when SwiftUI computes the body 🤷‍♂️ mastodon.notsobig.co/@phill/11

It’s hard to believe that I’m from a generation that paid for ringtones when should this stupid glass rectangle make a single noise now, I’d smash it to bits.

@mattiem right, because if the State is inside the Button it’ll be destroyed when the menu/swipe disappears, taking the dialogue with it.

Here’s one weird trick Apple DON'T want you to know:

If you present a confirmation dialogue from a swipeAction or contextMenu nothing will happen as the view is removed before the dialogue is presented. Annoying, but it makes sense.

Instead, delegate the confirmation to the environment. Now the Button isn't responsible for the presentation and you're left with a nice clean call site.

Here's my implementation with an example: gist.github.com/phillipcaudell

Show older
The Not So Big Company

The home of The Not So Big Company on Mastodon.