SwiftUI/Native Apple Development Discussion

MuseumShuffle,
@MuseumShuffle@mastodon.social avatar

Oh gross. My app has a sheet that can display a .confirmationDialog. In full screen mode the confirmation dialog is showing some weird behavior.

The worst is this variation where there's no message and only one of the buttons is partially visible.

The simulator for an 11" shows similar, but less weird behavior.

MuseumShuffle,
@MuseumShuffle@mastodon.social avatar

@kaybutter Oh my goodness, that was it. Because of @deanatoire I know that the cancel button not appearing isn't an issue.

After I moved the confirmationDialog to the Button itself it stopped doing that weird display issue.

Thank you both.

deanatoire,
@deanatoire@mastodon.social avatar

@MuseumShuffle @kaybutter oh, i got the modifier attached view issue on SharePal as well. Weird one but makes sense.

StewartLynch,
@StewartLynch@iosdev.space avatar

I have come across something with the Observation framework that is confusing me so if there are any Observation framework experts out there that can explain this to me, I would be forever grateful. Why I don’t have to define the object as a State object?

video/mp4

jonduenas,
@jonduenas@mastodon.world avatar

@StewartLynch I’m no expert, but I think this still runs the risk of losing MyObject state by getting reinitialized when the view reinitializes. I think your example just doesn’t run into that happening? Unless you’re asking about Observation in general, which doesn’t need any property wrappers for the view to be able to observe and update.

toddthomas,
@toddthomas@mastodon.social avatar

@StewartLynch already answered by actual experts in the time I took to make my example 😅, but yeah, the Observable macro does all the wiring of the property to SwiftUI’s observation mechanism. The State property wrapper saves the value to the heap so it can be preserved across view initializations where the view's identity is unchanged. Embedding the counter in a parent view whose identity changes demonstrates this.

Screen recording of Xcode shows how the Observable macro alone is all that’s needed for SwiftUI to update a child view when an observed property changes, but the State property wrapper must be added to the view’s reference to the observed object in order for its property value to be preserved when the child view initializer is called because its parent changes.

MuseumShuffle,
@MuseumShuffle@mastodon.social avatar

I just realized that if you're formatting to an abbreviated weekday then VoiceOver (at least Ava and Zoe Premium) will only fully pronounce some of the days.

I guess it's because the ones that aren't pronounced are actual words with other meanings? 🤔
Text(oneShowDay.formatted(.dateTime.weekday(.abbreviated)))

A simple app progressing through the abbreviated weekdays backwards starting with Friday.

ryanlintott,
@ryanlintott@mastodon.social avatar

@MuseumShuffle I guess “brightness higher” is technically true as well…

MuseumShuffle,
@MuseumShuffle@mastodon.social avatar

@ryanlintott I flip flop on that because sun.max is classified as "Weather" in the SF Symbols app and all of the other weather symbols have weather appropriate VO descriptions. But it does need to mean brightness higher in some scenarios.

bardi,
@bardi@mas.to avatar

Why am I made to jump through excess hoops to simply set the caret position to the very beginning of text in a TextEditor 😭

bardi,
@bardi@mas.to avatar

@davidbures mate, forget about formatting. I want the caret to start at 0. Not even that 😭 We have become beggars.

davidbures,
@davidbures@mstdn.social avatar

@bardi Man, for sure 😭 There are so many basic things missing

rafa,
@rafa@mastodon.design avatar
rafa,
@rafa@mastodon.design avatar

@ansel that was a good guess, but no dice 🫥

dzamir,
@dzamir@mastodon.uno avatar

@rafa I don't know about the specific problem, but my experience with SwiftUI is that when you try to use Apple’s "official” views, you will find many roadblocks and limitations; Still, you can build nearly everything pixel-perfect when you create your views from scratch.

So, my advice would be to not use a Toolbar but just a regular, custom SwiftUI view.

ctietze,
@ctietze@mastodon.social avatar

Does "flexibleSpace" in for macOS not work correctly?

Anything besides a Spacer() that's required in the item?

ctietze,
@ctietze@mastodon.social avatar

@Cykelero @stroughtonsmith So that's the culprit!

Ugh, of course we only get .inline and .inlineLarge, probably equivalent to .unified and .unifiedCompact, and need to resort to AppKit fiddling.

Starting with Windows in AppKit are still the best approach anyway. SwiftUI as the main app's driver is usually a disappointment.

lvalenta,
@lvalenta@mastodon.social avatar

@ctietze @jsq you bet. Well, to be completely frank, I’ve stopped feeling like this about Apple software. Not entirely, but bit by bit…

gallaugher,
@gallaugher@mastodon.world avatar

Back from sabbatical! More and content coming soon. Also info on how you can hire me to teach a bootcamp on these concepts or teach to faculty, leaving course material for use in their own classes. Feel free to share if you know educators who may be interested. https://youtu.be/DM8DUx1LkVg

kevinissac,
@kevinissac@mastodon.online avatar

Track My Domains is nearing completion! ✨ What are your thoughts? Any suggestions or ideas are welcome.

MuseumShuffle,
@MuseumShuffle@mastodon.social avatar

@kevinissac it looks nice!

See @rafa , you don’t get to use this.

rafa,
@rafa@mastodon.design avatar

@MuseumShuffle @kevinissac haha, oh don't worry, I still own way too many 🙈

rafa,
@rafa@mastodon.design avatar

My Safari window 10 minutes into development

bardi,
@bardi@mas.to avatar

@rafa @davidbures from memory that would make it work like a HStack, so yeah centered if you place it between two Spacers. Wait, you want a single button to fill the entire width of the Toolbar?

rafa,
@rafa@mastodon.design avatar

@bardi @davidbures like Safari's address bar

video/mp4

davidbures,
@davidbures@mstdn.social avatar

I wonder, is there a built-in AppKit/SwiftUI component that lets you show a folder structure like this? Or do you have to create a custo one? I can't think of a way to look this up 🤔

chrismarquardt,
@chrismarquardt@chaos.social avatar

@davidbures swiftui native breadcrumbs view is diy unfortunately

davidbures,
@davidbures@mstdn.social avatar

@chrismarquardt Thanks! That’s sad though, I’m really hoping for some SwiftUI on Mac improvements soon, but I’m not holding my breath 🥲

marcel,
@marcel@mastodon.social avatar

I'm not sure whether I love or hate this micro toggle. #SwiftUI #BuildInPublic

video/mp4

marcel,
@marcel@mastodon.social avatar

@PhilipTrauner Yes! Thank you!

marcel,
@marcel@mastodon.social avatar

Do you know that feeling when you finally arrive at "OF COURSE it should be like that"? I'm there now. This here is the right solution.

nwale,
@nwale@mastodon.social avatar

has been going well, but it always feels like there are little bits missing

ctietze,
@ctietze@mastodon.social avatar

@nwale heh, also big ones sometimes :D

teissler,
@teissler@hachyderm.io avatar

WWDC24 is right around the corner. Before the excitement and rush of what's to come, I want to share some navigation fun facts and tips. None of this is new, having been discussed previously in sessions, etc. From talking with developers, these are parts of the system that are often overlooked, or forgotten about This is all running on macOS Sonoma 14.4, Xcode 15.3

teissler,
@teissler@hachyderm.io avatar
  1. List selection can drive navigation pushes. You can populate the selection binding with a value-destination NavigationLink, or, any other way you would normally populate it.

A video showing a compact NavigationSplitView on iPhone Previews next to a code sample. The preview shows a list of with 4 elements, 3 navigation links, and 1 Text row. All 4 rows get a grey highlight when active. The non-navigation link row, the simple tagged Text, has no chevron, but still highlights gray in sync with the push progress. Code: import SwiftUI enum Sports: String, Hashable { case pickleball case dance case archery case volleyball } struct Day1: View { @State private var selection: Sports? var body: some View { NavigationSplitView { VStack { List(selection: $selection) { NavigationLink("Pickleball", value: Sports.pickleball) NavigationLink("Dance", value: Sports.dance) NavigationLink("Archery", value: Sports.archery) Text("Volleyball").tag(Sports.volleyball) } } } detail: { if let selection { VStack { Text(selection.rawValue.capitalized(with: .current)) Image(systemName: "figure.(selection.rawValue)") } } else { ContentUnavailableView( "Make a selection", systemImage: "volleyball") } } } } { Day1() }

teissler,
@teissler@hachyderm.io avatar
  1. NavigationStack and NavigationSplitView are intended to be used statically — establish the structure of your scene and generally don't move them around (there are some exceptions). Don't push a NavigationStack as part of a navigation destination. SwiftUI tries to warn in logs when it detects this.
    At the risk of teaching ChatGPT anti-patterns, here is an anti-pattern! Don't try this at home, or anywhere else you take your MacBooks.
gabtheodor,
@gabtheodor@mastodon.cloud avatar

A small SwiftUI Tip! 💡

Use the tint(_:) view modifier to change the foreground color of a Picker when using the .menu style.

ctietze,
@ctietze@mastodon.social avatar

@gabtheodor Can you share what this looks like, i.e. what's the consequence of that, and what would a misuse or forgetting this do?

dlx,
@dlx@mastodon.social avatar
gernot, German
@gernot@mas.to avatar

Checking and formatting phone numbers for app signup in . How hard can it be?

(Turns out: Hard. And I suspected that… Still sucks though.)

gernot,
@gernot@mas.to avatar

@ctietze @uliwitness There are other super crazy design decisions. PartialFormatter class that doesn’t conform to the Formatter protocol. The fact that their actual PhoneNumberFormatter does, but needs a „generatedPhoneNumber = true“, because its default mode is NOT doing formatting to PhoneNumber (and it silently fails in SwiftUI Textfields). And there is a Class called „Formatter“ in the framework that is not Foundations’ Formatter. (1/2)

gernot,
@gernot@mas.to avatar

And yeah, you can format using an instance of the PhoneNumberKit class.

It’s a madhouse. (2/2)

davidbures,
@davidbures@mstdn.social avatar

Rizzference is now out on the App Store!

https://apps.apple.com/cz/app/rizzference/id6474303013

It’s an app for looking up modern slang. What’s the niche? You can define an entire sentence at a time, not just individual words. Give it a go!

For the techies, it’s built 100% in SwiftUI. Feel free to ask any questions 😊

I’d like to thank all the testers and @chrismarquardt, @mattiem and @ctietze for their help and support.

dachary,
@dachary@dacharycarey.social avatar

@davidbures Nice! Congrats on the release! 🎉

davidbures,
@davidbures@mstdn.social avatar

@dachary Thank you! I really appreciate it 😊 You can give the app a try, maybe it will help in your career 😂

iamkev,
@iamkev@mastodon.social avatar

I love coffee, so I got a nice machine a while ago. Trying new beans means dialing in everything and considering all the nuances. I got tired of taking notes all the time, so I started building a small app that ideally replaces this little notebook.

Inspired by @marcel I want to and document my learnings along the way.

Let's call it 'Cofi' for now since it's the project's name in XCode.

marcel,
@marcel@mastodon.social avatar

@iamkev Exciting! 🤩

iamkev,
@iamkev@mastodon.social avatar

@marcel 🙌🏼 😍

hishnash,
@hishnash@mastodon.cloud avatar

Reacting to network status changes in SwiftUI doesn't have to be complicated. By converting NWPathMonitor into an AsyncSequence, you can handle updates efficiently and cleanly within your views. Discover how in my latest post:

https://nilcoalescing.com/blog/ReactToNetworkStatusUpdatesInSwiftUI/

michaelsteeber,
@michaelsteeber@mastodon.social avatar

I’m working on a project with an important launch animation that only plays on the first launch. Unfortunately, when people install the app via TestFlight, the “what to test" sheet obscures the animation. Has anyone found a way to detect when the sheet is dismissed?

clarko,
@clarko@mastodon.social avatar

@michaelsteeber I haven’t verified this yet, but I’d check Environment .scenePhase and restart the animation when transitioning to ScenePhase.active.

Even if it doesn’t solve your specific TestFlight sheet issue, it’d be a nice addition in the case where someone launched the app and got interrupted by something else/locked their phone/whatever.

michaelsteeber,
@michaelsteeber@mastodon.social avatar

@clarko great tip! Thanks!

gabtheodor,
@gabtheodor@mastodon.cloud avatar

💡Did you know?

In SwiftUI, you can 👉concatenate Text views👈 with different styles and still apply common view modifiers! For example, you can change the foreground style of Text views individually but group them to set a common font style! 😎

RosaCtrl,
@RosaCtrl@mastodon.social avatar

Am I the only one that thinks deprecating this modifier was a mistake? Any available alternative requires to keep the state in two properties, one for the data, another for its visibility, super annoying, so what I’m missing? https://developer.apple.com/documentation/swiftui/view/alert%28item:content:%29

RosaCtrl,
@RosaCtrl@mastodon.social avatar

@bde dang! I see no issue with it, seems to work flawlessly as SwiftUI only sets the presenting value to false. Now I wanna do some refactoring! (I still use the deprecated method as the annotation is wrong and Xcode doesn’t show the warning)

bde,
@bde@functional.cafe avatar

@RosaCtrl Glad it was helpful 🙂

kern,
@kern@iosdev.space avatar

I got most of the way through this ambient sound app last summer, and I may finish it once my current collaboration is in the App Store. I really like the icon for this one!

https://testflight.apple.com/join/wpWe5DET

phranck, German
@phranck@chaos.social avatar

Experts: Is it somehow possible to use breakpoints when UI testing a app and display debug output in the log?

phranck,
@phranck@chaos.social avatar

@dasdom Don't know. I do not have any UIKit projects.

dasdom,
@dasdom@chaos.social avatar

@phranck That’s a problem by its own.

gernot, German
@gernot@mas.to avatar

Question: I am using AnchorPreferences. Is there any way to use multiple AnchorPreferences at once? Like, use an array of points and communicating it up the hierarchy, but using a collection of [Anchor<CGPoint>] instead of the single Anchor<CGPoint> that the .anchorPreference modifier hands over?

gernot,
@gernot@mas.to avatar

@ctietze This is what I am doing. Essentially the whole „Anchor“ thing is just a fancy way of bubbling up geometry values in the „global“ CoordinateSpace, and it’s converted back at the point of use. I can do the whole ting myself by „convention“ thtat the points I use are global, but I’d rather do it with Apples wrapper that makes it explicit – if I can.

ctietze,
@ctietze@mastodon.social avatar

@gernot https://developer.apple.com/documentation/swiftui/preferences# The Preference API looks just like anchorPreference(...) -- but without the "anchor" in the name. You could create your overloads where Value is Array<Anchor<CGPoint>>

  • All
  • Subscribed
  • Moderated
  • Favorites
  • SwiftUI
  • slotface
  • kavyap
  • thenastyranch
  • everett
  • tacticalgear
  • rosin
  • Durango
  • DreamBathrooms
  • mdbf
  • magazineikmin
  • InstantRegret
  • Youngstown
  • khanakhh
  • ethstaker
  • JUstTest
  • ngwrru68w68
  • cisconetworking
  • modclub
  • tester
  • osvaldo12
  • cubers
  • GTA5RPClips
  • normalnudes
  • Leos
  • provamag3
  • anitta
  • megavids
  • lostlight
  • All magazines