Empower Apps

I had a great time chatting with Chris Eidhof about his work with objc.io and his latest project, the SwiftUI Field Guide. We discussed SwiftUI's layout system and the exciting new features from WWDC 2024.

Guest

Announcements

Links

Related Episodes

Social Media

Email
leo@brightdigit.com
GitHub - @brightdigit

Twitter
BrightDigit - @brightdigit

Leo - @leogdion

LinkedIn
BrightDigit

Leo

Patreon - brightdigit

Credits

Music from https://filmmusic.io
"Blippy Trance" by Kevin MacLeod (https://incompetech.com)
License: CC BY (http://creativecommons.org/licenses/by/4.0/)
  • (00:00) - Chris's Journey in iOS Development
  • (03:39) - SwiftUI Field Guide
  • (24:11) - WWDC 2024
  • (36:14) - Is SwiftUI Production Ready?
Thanks to our monthly supporters
  • Holly Borla
  • Bertram Eber
  • Edward Sanchez
  • Satoshi Mitsumori
  • Steven Lipton
★ Support this podcast on Patreon ★

Creators & Guests

Host
Leo Dion
Swift developer for Apple devices and more; Founder of BrightDigit; husband and father of 6 adorable kids
Guest
Chris Eidhof
Founder of https://t.co/IxXRXih1Sr — Hardly here anymore, moved to @chris@m.objc.io

What is Empower Apps?

An exploration of Apple business news and technology. We talk about how businesses can use new technology to empower their business and employees, from Leo Dion, founder of BrightDigit.

[00:00:00] Chris's Journey in iOS Development
---

[00:00:00] Leo Dion (host): Hey folks. Before we begin today's episode, I wanted to let you know I'm open to new opportunities this summer and fall of 2024. If you're looking for someone who has an expertise in swift, whether it's iOS, watch, os, tv, vision, Mac Os, or Server side, swift, reach out to me. You can find me@brightdigit.com and you can reach out to me there, or you can just email me at leo@brightdigit.com.

[00:00:27] Leo Dion (host): Thank you so much, and I hope you enjoy the rest of today's episode.

[00:00:34] Leo Dion (host): Welcome to another episode of Empower Apps. I'm your host, Leo Dion. Today we're joined with Chris Eidhof. Chris, so happy to have you on. Thank you for coming today.

[00:00:46] Chris Eidhof (guest): Thank you. Thank you for having me. So great.

[00:00:49] Leo Dion (host): For people who don't know who you are, I'll let you go ahead and introduce yourself.

[00:00:54] Chris Eidhof (guest): Sure. Yeah. I'm Chris and I've been doing iOS development since iOS two. Somewhere around iOS three or four I thought oh, we're over it. Like it's, this was it. And I never guessed I would still be here doing iOS and Mac and Swift and all of that stuff. And yeah at some point I started UI Con conference in Berlin and out of that came objective c io and magazine we ran back in the day for two years.

[00:01:21] Chris Eidhof (guest): And then. We started writing books. So we as Florian and Daniel and me the creators of objc.io. And then yeah, then at some point a video series called Swift Talk. And the, my most recent project is the SwiftUI Field Guide. And yeah, but I'm, I've been in the community for a long time now, I think and really enjoy it, really enjoy the people there and yeah.

[00:01:46] Leo Dion (host): Yeah. And I love the work you've been doing on objc.io, swift talk and all that stuff. It's been fantastic. Did you, when did you start writing like educational material? What year would you say?

[00:02:00] Chris Eidhof (guest): Yeah. This was I think 2013. So we started UIKonf the conference because I really wanted to go to a conference, but. In Berlin, there was none except for German speaking ones. And I'm not a native speaker, and so I wanted to go to an English speaking one, and so I had to organize it. And then the day after the conference, there were a couple of us sitting outside feeling guilty because we were just chatting and not participating in the hack day.

[00:02:28] Chris Eidhof (guest): But that's where we started the magazine. And I think that's where we started writing sort of educational content. I. Didn't really know too much, like in depth stuff at all. But Florian and me, we had a lot of time in our hands. And Daniel, who was also part of that team, he knew everything. Like he knew all the he had all the knowledge but didn't have that much time.

[00:02:50] Chris Eidhof (guest): And so the combination was perfect because we could just write stuff and he'd be like, oh no, this is all wrong.

[00:02:56] Leo Dion (host): Yeah.

[00:02:56] Chris Eidhof (guest): And that's how you learn.

[00:02:57] Leo Dion (host): yeah. That's awesome. What are you, what's your native language?

[00:03:02] Chris Eidhof (guest): Dutch. Yeah. Which is the same as German almost.

[00:03:05] Leo Dion (host): Deutsch Dutch, it's all the same. Yeah. Objective C Swift, it's all the same. Yeah. So it's funny that you said 2013 'cause that was like the year before Swift came out and you must have been like, oh, we started this domain objc.io and now there's a new language

[00:03:20] Chris Eidhof (guest): Yeah, somebody immediately grabbed swift.io and then we stuck with the name. And so we write these books like about Swift and I've heard of people not buying the book because the first thing on the cover is objective C and like the, it makes people not want to buy the book. But yeah, it's fine.

[00:03:36] Chris Eidhof (guest): They're loss.

[00:03:38] Leo Dion (host): Yeah, exactly.

[00:03:39] SwiftUI Field Guide
---

[00:03:39] Leo Dion (host): So today we wanted to talk about your field guide, your SwiftUI field guide. You wanna explain exactly what it is and what's it for.

[00:03:48] Chris Eidhof (guest): Yeah. So out of this educational stuff at some point we started doing workshops and I workshops about SwiftUI and I realized it's very, like there's not a lot of really good documentation by Apple itself on how SwiftUI actually works. There's. WWDC talks, there's API documentation, but not nothing explains the layout system, for example.

[00:04:11] Chris Eidhof (guest): And so our workshops have been focused on that, but it's also been a frustration for me because I don't think people should be like paying a lot of money to, to attend a workshop with their company like this. This information should be open and should be free. And so that's why I created the field guide.

[00:04:28] Chris Eidhof (guest): I wanted to create a resource where people. Can read about the layout system, understand it, link to it to send it to their coworkers or whoever needs it, and also play around with it. And there are a lot of these really good explainer websites out there these days. And I got really inspired by that.

[00:04:49] Chris Eidhof (guest): So for example, if you wanna look at the padding modifier I made it so that. In all the examples, if there are any tweakable values, you can adjust them with a slider. And I picked that up somewhere in a talk. I don't know if it was Brett Victor or one of these people who's really good at this.

[00:05:06] Chris Eidhof (guest): And by having a slider you can go through so many intermediate values in such a short time that you really get a feeling hopefully for how this stuff works. And and yeah, that's what I've been really focusing on trying to. Explain some of the top these topics in a very visual way. That's hopefully fun to interact with.

[00:05:26] Leo Dion (host): When it comes to the field guide, so is the field guide completely free for anyone to consume?

[00:05:32] Chris Eidhof (guest): Yes. So currently it's completely free and I think I would like to be able for this to be a project that can I. Carry its own weight so that it pays for itself. I like, so it is, it's a, it is a, I think it's a big loss machine currently every month. But but we'll get there at some point.

[00:05:50] Chris Eidhof (guest): I think I wanted ideally I would like to give away as much as I could, but of course I need to pay the bills as well and I have two kids. And like I, I need to make sure that it can sustain itself at some

[00:06:02] Leo Dion (host): that makes total sense. So what do people not know about the layout system that they should know?

[00:06:10] Chris Eidhof (guest): Yeah, I think it's the mechanics of how it works. So I'll have people in my workshop who've been doing SwiftUI in production for two years. I. And and they know how to use it, right? And so they can get their stuff done and they can make it work, and then it doesn't work. And then they have this repertoire of tricks that they can apply.

[00:06:29] Chris Eidhof (guest): Like you can try maybe a fixed size or one of these things,

[00:06:34] Leo Dion (host): geometry

[00:06:34] Chris Eidhof (guest): to reader.

[00:06:35] Leo Dion (host): and fixes everything.

[00:06:36] Chris Eidhof (guest): Yeah, see if that works. Or maybe I could use an alignment guide or maybe not. Like I didn't really know. And so that's my experience that people come in with a pretty sound understanding, but not really at the core.

[00:06:48] Chris Eidhof (guest): And it's actually really simple, the whole layout system. It's this dance of a parent proposes and a child response and this's almost the only thing to it. And then every view responds in a different way to the proposals. And so just. Just the idea of that, I think, and the fact that you take your swift code and that gets turned into a tree, I think is either a complete eye-opener or it finally helps people to make the whole thing click, right?

[00:07:16] Chris Eidhof (guest): Like they, they know this, but they don't really, and then I can show them the last final bits and then it all makes sense. Like that's very rewarding if that happens ever during teaching. And so that's. What I noticed that people just often don't really understand and hopefully this will help.

[00:07:33] Leo Dion (host): When did it click for you that you were like I get this,

[00:07:37] Chris Eidhof (guest): Oh,

[00:07:38] Leo Dion (host): how to communicate this to other people.

[00:07:40] Chris Eidhof (guest): there is no one moment.

[00:07:41] Leo Dion (host): Okay. Okay.

[00:07:42] Chris Eidhof (guest): But I can tell you there's a few, there's a few moments where it's started making. A little more sense. Like I remember at some point we were writing the first edition of Thinking in SwiftUI and I I actually did that in like a holiday home, not far from where we live.

[00:08:00] Chris Eidhof (guest): So that I had like isolation, no internet, no nothing. And I was trying to figure this out. And then I was rewatching a WWDC video by John Harper and Dave Abrams, and it said something like, yeah, and if you propose this, and I was like, wait. What if it actually literally proposes, like, how would that work?

[00:08:19] Chris Eidhof (guest): And then I started to figure that out and what really helped me to actually understand is trying to replicate that by implementing myself. And so that really started to like doing more and more of that really helped me to get that click effect.

[00:08:36] Leo Dion (host): Before we get into kind of the more in depth of what that means what was your background as far as design and development before Swifty y?

[00:08:49] Chris Eidhof (guest): Yeah,

[00:08:50] Leo Dion (host): So UIKit, like obviously, but like what else have you were, did you do besides that

[00:08:56] Chris Eidhof (guest): Yeah. I used to do web development, so mostly actually PHP. And mostly backend stuff. I, when I was younger, like a teenager, I would do like the whole thing, right? HTML, CSS, PHP everything and the design and make no money. But like we would build websites for like local companies.

[00:09:16] Chris Eidhof (guest): And and then and then I went to university and there it was super hascal heavy and that really.

[00:09:23] Leo Dion (host): interesting.

[00:09:24] Chris Eidhof (guest): Really yeah, enlightened me like I, I did my masters trying to I came in with the question, is this Haskell thing actually something you could take seriously? Is this a real thing or is this just a toy?

[00:09:38] Chris Eidhof (guest): And it turned out to be real. And we got, we had this was the coolest thing ever. We had this group of students that were super motivated and so we were the, it was very contagious. Like we were all like really getting into it and like going to conferences and trying to one up each other all the time.

[00:09:54] Chris Eidhof (guest): And the learning Yeah. In Haskell and the learning in those two years was so intense and so amazing. And I still like, when I talk to these people now it's just it's really interesting. It just I don't know if I could do it today. But back then we have a lot of time and a lot of motivation.

[00:10:11] Leo Dion (host): There you go. Yeah, exactly. So the reason I was asking is 'cause I think like one of the things you go into it SwiftUI, you have, you're already your precon. I've talked about this before. When it comes to education, one of the biggest problems is those of us who are experienced come at it with different.

[00:10:28] Leo Dion (host): Mind models of how things work. If you were doing UIKit, like you had a specific, you had a better under, you had a specifically UIKit understanding of how layout would work. And like for me, it's either that or it's gonna end up being CSS. Because that's I've still do it at the occasional web development stuff and I've done a lot of with like CSS and how CSS talks to pa, like parents and children, all that stuff.

[00:10:51] Leo Dion (host): So I feel like that's one of the. Not necessarily blockers, but like paradigm ships you have to let go is like how Suit UI does it differently than other systems. Do you know what I

[00:11:03] Chris Eidhof (guest): Oh yeah. No, it's it, this is literally why we called our book Thinking in SwiftUI because it does not really matter how good you are. ui, you can transfer over almost none of that knowledge to SwiftUI. So there's no auto layout, there's no, the state system is different. The animation system is completely different.

[00:11:24] Leo Dion (host): And it's all UIKit underneath, but like it's SwiftUI. And I think Paul has said this is like SwiftUI is just like a series of instructions and then each operating system draws it, like in whatever language it uses underneath the applicate UIKit, whatever. And it's more it's more like a markup in a sense with the DSL and everything.

[00:11:45] Chris Eidhof (guest): It is and I wonder if at some point, like. The so clearly UIKit will be there and is necessary like the whole UIV representable, but like for a lot of the basic components, they could just pull out the rug and re-implement those in SwiftUI without us noticing. Like in theory, like it doesn't need to stand on top of you.

[00:12:07] Chris Eidhof (guest): I could, I think it could move towards being its own thing and everything is SwiftUI and then it integrates with your IT if you choose to.

[00:12:15] Leo Dion (host): I'm not, I feel like I haven't been in the industry long enough to see Apple actually do that with it, with API, where they're just like, everybody was using cocoa or whatever, and it's like all of a sudden you have to go to AppKit and then eventually everything is an AppKit. So yeah, I'm sure that's kinda like the long term plan.

[00:12:32] Leo Dion (host): But yeah, it would be interesting to see like them actually pull the rug out and be like, everything's down.

[00:12:37] Chris Eidhof (guest): I don't know if that's gonna happen. I have no idea. I think they could, and but let's see. Maybe they cannot,

[00:12:43] Leo Dion (host): I would say five years, 10 years. Like it's gonna take a while. Like it's not gonna happen anytime soon.

[00:12:50] Chris Eidhof (guest): Yeah.

[00:12:52] Leo Dion (host): Yeah, let's get into it. You were talking about the pattern propose or the parent proposes to the child and the child implements. Did I say that correctly?

[00:13:01] Chris Eidhof (guest): Yes.

[00:13:02] Leo Dion (host): does that, let me see if, let me see if I understand correctly, and you could correct me if I'm wrong.

[00:13:06] Leo Dion (host): The parent's Hey, I'm a box that's 500 by 500 and I want you to only do the left side. Or leading I should say. Is that like how it works and the child's no, I think I want to be bigger than you and I'm gonna be 800 by 500, and the child can just do whatever it wants. Is that correct?

[00:13:25] Chris Eidhof (guest): yeah, almost so the parent proposes, let's say the parent proposes a size to its children. And so the root view would be like the whole device, right? The whole safe area. And so that would propose the size of the safe area, and that's for all time sake. Say that it's three 20 by four 80, and then the child can do whatever it wants with the proposal.

[00:13:48] Chris Eidhof (guest): And so there's different behaviors. If you have an app that's only a rectangle, let's say a yellow rectangle, it's gonna fill up the entire safe area. So in, in other words, what it does, it, it just takes the proposal and returns it and saying, Hey, that's my size. Things like a padding, say wall.

[00:14:08] Chris Eidhof (guest): I'll take the proposal, I'll subtract a little bit and propose that subtracted smaller version to my child. And and so then it adds it back up and, to the reported side of the child. And then you have things like H Tech and that. Those are super interesting, I think H Tech and V Stack because what they need to do is somehow distribute all of that available space, right?

[00:14:28] Chris Eidhof (guest): So let's say you have 300 points available, you have three sub use. And what the H Tech actually tries to do, roughly is to distribute that equally to each of the sub views which sounds easy, but in practice it's actually quite tricky

[00:14:44] Leo Dion (host): Yeah, I would imagine yes.

[00:14:45] Chris Eidhof (guest): Because, like maybe one of the sub views is only ever gonna be 10 points wide, so then it needs to know that before and maybe distribute the space among the other two and do that in the right order.

[00:14:55] Chris Eidhof (guest): And so it becomes this really fun dance. And the reason I think why we need to understand it is mostly we don't. And then we get into trouble because it doesn't do what we want. And then all of a sudden, like you need to fill in that knowledge and understand what happened there.

[00:15:12] Leo Dion (host): Are there like protocols or something available that would let us. Do this ourselves, so that way we can actually see it in action, if

[00:15:20] Chris Eidhof (guest): yes. Yeah so the layout protocol does this, so the layout protocol lets you do exactly that dance, and it got available in iOS 16. And the macro has released that came of that and it all let us write around layouts. And it's the first time as Swift U developers that we saw the proposed view size strict and.

[00:15:41] Chris Eidhof (guest): You can actually do layouts that are completely no up. So they just forward everything and return everything from their respective children. But you can print stuff and this is how you can. Visualize or introspect what's happening there. So if you do this no up layout and wrap every H Tech child in that, you'll see that the H Tech proposes three times to every single child to figure out, like flexibility and then it

[00:16:09] Chris Eidhof (guest): It's really fun.

[00:16:11] Leo Dion (host): What other quirks that you think people don't know about how the layout system works in SwiftUI or that or not quirk, but necessarily that doesn't meet the expectation of what the typical SwiftUI developer thinks?

[00:16:26] Chris Eidhof (guest): I think a lot of people so there's maybe two things. A lot of people seem to think that this gets translated into constraints or into auto layout, which is not at all what happens.

[00:16:36] Leo Dion (host): SwiftUI just tell directly the UIKit. This is exactly what I want you to do, and don't shut up and just do it

[00:16:42] Chris Eidhof (guest): or not even UIKit, like a rectangle or a text. I don't think that's UIKit anymore. It's just,

[00:16:48] Leo Dion (host): Oh, okay.

[00:16:49] Chris Eidhof (guest): yeah. So the thing we see on screen, I think is I think they call it a display list. And it's like literally the list of views that needs to be displayed with their respective frames so that their position and size and.

[00:17:02] Chris Eidhof (guest): So the whole thing that SwiftUI does is like everything with the layout system and whatever, the animation system just to get the display list out. And yeah, as for the things that people like, another thing that I don't think many people understand is that when SwiftUI proposes. Either of those dimensions.

[00:17:20] Chris Eidhof (guest): So either the width or your height could be nil and that seems like a funky edge case, but it's actually really important to what's happening underneath. So a nil proposal means that the view can become its ideal size in that dimension. And so if you propose a nil width, it basically says become your ideal width.

[00:17:41] Chris Eidhof (guest): And this is used everywhere. So there's the dot fix size modifier. And that does that for you. It, it sends you a nil proposal and also in a scroll view, if you imagine like a vertical scroll view, right? You have so much space available, like almost infinitely. And so this, the vertical scroll view will do a nil height proposal and tell each of its sub views Hey.

[00:18:03] Chris Eidhof (guest): Become whatever height you want to be, right? Become your ideal height. And this, it's the same for aspect ratio. The aspect ratio, modifier uses is to figure out the underlying aspect ratio. And so there's a lot to that. And then I think the other thing that people maybe don't really get and who's, that's so understandable is that code that the code that we write gets turned into trees. And like that tree is super important for the order of proposals and the order of everything. And but that's maybe a more fundamental thing than just layout. Yeah,

[00:18:35] Leo Dion (host): Do you two questions. What, how do lazy collections work? So we have a lot of these like lazy grids, lazy stacks. How do those work and how do those affect the layout system?

[00:18:47] Chris Eidhof (guest): I, so I don't know how they work. Like I, I can tell you, I can tell you how I can describe you, like what my mental model is of them but obviously, like I've never looked at the source. 'cause I wouldn't really know. I can only I can tell you how they work. I don't know how they're implemented.

[00:19:03] Chris Eidhof (guest): So the,

[00:19:05] Chris Eidhof (guest): Yeah, so let's say if you have a lazy V stack. It's not gonna be lazy at all unless you have this specific combination of a scroll view with a lazy stack, and then let's say a four each in there. And what it's, what it's going to do is it'll try to create only the sub views that are necessary to fill up the bounds of the scroll view.

[00:19:30] Chris Eidhof (guest): So not the. The whole region. But if you scroll to position Y is 100 then it doesn't need to render the first few views only like everything from position a hundred onwards. And so it's very similar to UI table view for those that are familiar with your iki in that it just cre I think it creates the views lazily.

[00:19:52] Chris Eidhof (guest): And in order for that, the views need to be lazy. So if you have like a. A scroll view and then and then a lazy vs stack and then a bunch of static views. I don't think SwiftUI could make those, could create those lazily. It's only by having a lazy container, like for each, that it can do that.

[00:20:07] Chris Eidhof (guest): And one really interesting thing is that now with iOS 18, we can create our own lazy containers using the four each and using the group modifiers. So only. That will be that you choose to draw will be rendered. And so it's not so easy to recreate like lazy vs. Stack, I think but you could do it.

[00:20:32] Leo Dion (host): Yeah, I want to talk about that a bit. So we got this idea of like custom view collections. So what I was thinking is I'll have a case. Oh basically what I've been doing lately with Bushel is I create this on Mac app is I create like a kind of a view page. No. Yeah, page view controller, if you're familiar with that, where you like can go page to page like, so I had to create my own custom one and I ended up having to create this identifiable view and then put it in a group and blah, blah, blah and all this stuff.

[00:21:05] Leo Dion (host): This is I'm not gonna need to do all that stuff anymore. With a view, with a new view collection stuff. Is that correct?

[00:21:11] Chris Eidhof (guest): I think so, yeah, I think you still might need to make sure that you have stable identity for your views, but you can build your own page view out of the new group and for each stuff. And so I

[00:21:24] Chris Eidhof (guest): I. And you could make that lazy, so you could only display like the current page. So I did something similar, like a, almost like a low tech version of cover flow where it displayed like the middle page and then the one before and the one after.

[00:21:40] Chris Eidhof (guest): And it had a million items and you can just scroll through them and it only renders to three that are currently necessary. And. Took a little while to figure out, but it was not very complicated at all in the end.

[00:21:52] Leo Dion (host): Yeah, the pain in the butt part for me was a, I had to create a function, no result builder, and I had to create the identifiable part, so that way it's actually identifiable. Otherwise, yeah, it seems to be working pretty good on the Mac, so I'm happy with that.

[00:22:08] Chris Eidhof (guest): For me it was also the way to make it work was pretty tricky because you do need this to make sure that your views have the stable identity. Otherwise SwiftUI considers your views to be new ones and then you lose any associated state or animations or any like the, anything like that.

[00:22:24] Leo Dion (host): Yeah. I was using UUIDs and then I was like, it would create a new one every time I mess stuff up. And I was like, no, I'll just go back to integer and. nice.

[00:22:33] Chris Eidhof (guest): Yeah. No, yeah that's a thing for sure.

[00:22:36] Leo Dion (host): Is there anything else you wanna talk about the field guide before we talk about the exciting new stuff from Dubbo this year?

[00:22:43] Chris Eidhof (guest): Yeah. So maybe one fun thing is that, in order to make it work, I actually re-implemented whole parts of SwiftUI in TypeScript. Also just so

[00:22:51] Leo Dion (host): right, you told me this. Okay, go ahead. Sorry.

[00:22:54] Chris Eidhof (guest): It was, it got out of hand a little bit. Like I, I was just trying to reimplement some of the layout system in JavaScript. And then actually the friends from university, my Hasco friends, I met up with them for the first time in 10 years and they all told me to switch to TypeScript.

[00:23:11] Chris Eidhof (guest): And so I switched to TypeScript and it started doing that. And you can get very close to, to what Swift is doing. And so my syntax, I don't think it would feel. Native to anybody who writes typescripts or TypeScript or HTML, but it reads almost like SwiftUI and there's a lot of quirks and like weird bugs in there, but I know exactly where they are and I can work my way around them.

[00:23:35] Chris Eidhof (guest): And so I'm the only consumer of the API, so it's fine. But that's what I did to make it work. And

[00:23:41] Leo Dion (host): That's funny.

[00:23:42] Chris Eidhof (guest): and if you look at the website, I think it looks. Hopefully it looks mostly pretty simple. Like not very complicated, but almost everything that's interactive there, like the whole explanations, for example, on the H Tech page, this is all sort of fake SwiftUI which made it possible for me to iterate that much quicker.

[00:24:02] Chris Eidhof (guest): Like all the animations. It's all my fake Swift J implementation.

[00:24:07] Leo Dion (host): That's amazing. That's awesome. Yeah. Let's get into it.

[00:24:11] WWDC 2024
---

[00:24:11] Leo Dion (host): Besides view collections, what else was your favorite thing from dubbed up this year concerning swifty y.

[00:24:17] Chris Eidhof (guest): Yeah, I think that I really like that. I think. I like the animations talk a lot by Rob and Philip. Like there was such a good talk and such a fun thing to watch and so they showed I think a lot of my favorite things. There's now the color mixing, I think it, it seems

[00:24:34] Leo Dion (host): the gradients.

[00:24:35] Chris Eidhof (guest): Yeah so you can mix colors yourself now, where you can say I have like color A and color B, and I want to, I interpolate between those. And you can do that in the okay. Lab color space rather than RGB. And I think the gradients do this as well, like even linear gradient. And then yeah, the whole mesh gradient stuff looks awesome.

[00:24:56] Chris Eidhof (guest): I think everybody was on Twitter, was writing mesh gradient editors immediately.

[00:25:01] Leo Dion (host): So what's I don't get, I don't get it because, I get it. Like mesh gradients are cool, but what's the use case for them besides they look cool. That's a bad thing. But like what is there a specific design pattern where that's like

[00:25:16] Chris Eidhof (guest): Maybe, I don't know. I think

[00:25:18] Leo Dion (host): Okay.

[00:25:19] Chris Eidhof (guest): I think they just look cool and they it's hard to do this without a mesh gradient. And actually one thing I am really excited about is that almost every, or not almost everybody, but a lot of people will now be able to move towards, I was 17, last year's release, but

[00:25:35] Leo Dion (host): makes a big difference. Yeah.

[00:25:37] Chris Eidhof (guest): it makes a big difference.

[00:25:38] Chris Eidhof (guest): And then we get shaders and I really, I don't understand shaders well enough but I think those, they I understand them well enough to know that it has a lot of potential and so I. My thought was that mesh gradients would be pretty easy to implement using a shader. And like always, it's probably one of these things that's maybe easy for the first 80% and then to get it right, it's like a year more of work.

[00:26:05] Leo Dion (host): Have you done anything with metal or have you even have the desire to Okay. Because that stuff gets in right.

[00:26:14] Chris Eidhof (guest): I've I, it is still hard for me, all the math and all the matrixes. I picked up a book on I had funny thing, I have it lying right over here. I picked up a book on on matrix and linear algebra and all of that stuff. Yeah.

[00:26:28] Leo Dion (host): I don't miss that stuff.

[00:26:30] Chris Eidhof (guest): I would want to understand it better, but I don't.

[00:26:34] Leo Dion (host): Okay, so let's go over some of the things we got with 50 Y this year. There's a new tab experience for the iPad. What's, do you have an opinion on that at all?

[00:26:44] Chris Eidhof (guest): I know I've not owned an iPad for, what is it, 10 years

[00:26:49] Leo Dion (host): Yeah.

[00:26:50] Chris Eidhof (guest): maybe? And so no I don't really like, so into all the little details in SwiftUI that I consider those things to be more pla platform than SwiftUI. And so it, I feel like it's outta scope for what I do. I struggle trying to understand all of the the fundamentals of SwiftUI even and yeah, I

[00:27:10] Leo Dion (host): It's cool and I think it's been a long time coming, 'cause I think people don't really use tabs as much as they used to anyway. So it makes sense that they bumped 'em up to the top and put them out of the way, which I kinda like.

[00:27:23] Chris Eidhof (guest): Yeah. I think,

[00:27:25] Leo Dion (host): yeah, go ahead.

[00:27:26] Chris Eidhof (guest): oh, no, I was gonna say maybe one thing I, that I, so there's maybe two things that I really enjoyed it that were new is that sort of, that we now get for adding things. Sorry.

[00:27:37] Leo Dion (host): You mean entries?

[00:27:39] Chris Eidhof (guest): Yes. Yeah. For, so for, we get this for environment values, for what else Is it like all the trait stuff like the layout values and it just so much nicer.

[00:27:50] Chris Eidhof (guest): Like it's so much work to type in an environment key.

[00:27:54] Leo Dion (host): There's so much in bushel, there is so much boilerplate code

[00:27:58] Chris Eidhof (guest): I know. Yeah.

[00:27:59] Leo Dion (host): Like I created so many environment values and it's copy paste. There you go. It's per, it's not perfect for a macro, honestly. Like it makes total sense. Yeah, that's that's awesome. Unfortunately I won't be able to use it.

[00:28:11] Leo Dion (host): I guess could I use it?

[00:28:13] Chris Eidhof (guest): I think you could. Yeah, I

[00:28:14] Leo Dion (host): because it's got, yeah, 'cause it's a back deploy. 'cause it's a macro, it's not like it's a new API yeah. Technically I could use it.

[00:28:22] Chris Eidhof (guest): Yeah. And even if you couldn't, you could write your own macro and do your own version of it.

[00:28:27] Leo Dion (host): Exactly.

[00:28:27] Chris Eidhof (guest): it's like this would be a very good starter macro to write also for people who wanna get into it. I've been doing a little bit of macro development and I found it very hard. Just so much by the plate.

[00:28:41] Leo Dion (host): It is really hard. Swift and Texas is really hard. Yeah, I agree.

[00:28:46] Leo Dion (host): But that's a perfect one, like you said,

[00:28:48] Chris Eidhof (guest): Yeah, no, it is. Yeah. And I was gonna say one other thing that I enjoy that they added is the the new geometry change thing where you can measure the geometry of a view. And this is the stuff we would always teach in a workshops where you do an overlay in a geometry reader and a color clear and a preference or an on change or something like that.

[00:29:07] Chris Eidhof (guest): And.

[00:29:07] Leo Dion (host): right.

[00:29:08] Chris Eidhof (guest): all of that stuff got so much simpler. Now, if you wanna just measure a single view, you can now do that in two lines instead of six lines And a preference key.

[00:29:18] Leo Dion (host): Yeah. Have you done, is there anything? So there's the new Swift, speaking of macros, there's the new swift preview macros for like data, like test data, essentially. I,

[00:29:29] Chris Eidhof (guest): Oh yeah.

[00:29:30] Leo Dion (host): that looks awesome. I still have issues with trying to get previews to work half the time, but

[00:29:35] Chris Eidhof (guest): You do? Yeah. They work for me but I'm not a typical developer because we always make like new projects and And so my projects are typically not very big and like for small projects that work great. And I think I mean it does take a little bit of setting up I think you, you wanna keep your previous very simple in the same way that you wanna write code.

[00:29:58] Chris Eidhof (guest): That's easy to unit test, where

[00:30:01] Leo Dion (host): Yeah,

[00:30:01] Chris Eidhof (guest): if your previews need a lot of dependencies and like networking and all of that, it's just not really worth it and it's hard to use. But if your previous can be super isolated from that, then you can, you might be able to make it work for you.

[00:30:15] Leo Dion (host): Yeah, you sound just, Brandon said that when he was on here he was like, yeah, if you can like previews and unit tests all, if you can separate your dependencies out, it's gonna make it a lot easier for you in the long

[00:30:26] Chris Eidhof (guest): Exactly. Yeah.

[00:30:29] Leo Dion (host): did you do, have you done any widget stuff?

[00:30:32] Chris Eidhof (guest): I have not. No. I wish and I wanna build apps with widgets, and I know people have problems with this, right? Like people struggle on Slack with getting the widgets to work

[00:30:42] Leo Dion (host): update and having him inter, because you can interact with him at least since the last version, I wanna say.

[00:30:48] Chris Eidhof (guest): yeah, maybe. Yeah. I don't even have let me check. I think I have. I don't, no, I don't have any widgets on my phone. Even. I'm super,

[00:30:57] Leo Dion (host): Oh my gosh. Not even a photo of your kids. Come on.

[00:31:01] Chris Eidhof (guest): no, it's on my home screen and on my lock screen, but not on my, I don't have widgets. No.

[00:31:06] Leo Dion (host): gosh. Okay. We should cut that out. That's so embarrassing.

[00:31:09] Chris Eidhof (guest): Get it set up tonight.

[00:31:11] Leo Dion (host): You're still on iOS 16 or 16? Yes. 17. I always get confused. There's so many.

[00:31:19] Chris Eidhof (guest): I'm also very hesitant. I don't know, like it I just have the one phone and I don't wanna lose like my iCloud stuff. Or

[00:31:28] Leo Dion (host): Oh, that makes sense.

[00:31:29] Chris Eidhof (guest): And yeah. And it's the same with, I used gui, Rambo's virtual machine thing, so virtual body to test out the new version of Macs, which was awesome.

[00:31:39] Chris Eidhof (guest): And I, it was it worked super smoothly. It's absolutely worth it. We should link to that in the show notes

[00:31:46] Leo Dion (host): No, we should link to Bushel. Why would I wanna link to Virtual Buddy?

[00:31:50] Chris Eidhof (guest): Oh, sorry.

[00:31:51] Leo Dion (host): Oh my gosh, Chris.

[00:31:53] Chris Eidhof (guest): No. I think there's, it is a big world out there. So really wanted to test out the AI stuff in Xcode. But that doesn't work in a virtual machine.

[00:32:02] Leo Dion (host): oh yeah. 'cause okay, that makes sense. Yeah. It's cool. It's fine.

[00:32:07] Chris Eidhof (guest): I've, so I've

[00:32:09] Leo Dion (host): I haven't been super impressed with it, but I also haven't been like disappointed in it. I'm just like. It's better than what we had before, but Yeah.

[00:32:18] Chris Eidhof (guest): I know people are gonna hate this, like some people are, but I've used copilot a whole bunch in vis Visual Studio Code for

[00:32:26] Leo Dion (host): If you've been doing TypeScript Yeah, exactly. It is totally awesome. Yeah. Yeah. So I build web front ends for my apps and we use, I use TypeScript and it's awesome that CSS HT ML.

[00:32:40] Chris Eidhof (guest): Yeah.

[00:32:41] Leo Dion (host): that's the, that is Chris, you're gonna, you're gonna be disappointed with the

[00:32:45] Chris Eidhof (guest): Okay. Yeah. Let's see.

[00:32:46] Leo Dion (host): to copilot, copilot is much better.

[00:32:48] Leo Dion (host): Now, obviously, copilot like has the entire database of all the code on GitHub at its disposal, whereas the Swift assist stuff is not for pri good privacy reasons. You get what you get.

[00:33:03] Chris Eidhof (guest): So my favorite moment was when I was, so I actually have I don't know, seven or eight different re-implementation of Swift unit that all do a different part, right? Like a maybe the HStack layout or maybe one has like the state system or the animation system and all are broken in their own way.

[00:33:20] Chris Eidhof (guest): But I took my HStack layout algorithm in Swift and I pasted it in my TypeScript file because I wanted to port it right and I wanted to have a reference there. And I started typing. Copilot translated that whole algorithm for me, line by line from Swift into TypeScript. And it was like, so good.

[00:33:42] Leo Dion (host): That's amazing. Yeah.

[00:33:44] Chris Eidhof (guest): I don't trust it to write my code. I trust it to help me write my code. And I don't feel like you could let those things like write code and then just run it. Like I review every single line and I try to really understand it.

[00:33:58] Leo Dion (host): Could you imagine if we had a co-pilot for writing macros? Do you know how much easier that would be? Like that would be a perfect example of like where co 'cause there's just like you sat, there's so much pre-code that like you have to do over and over again for swift syntax and if ChatGPT had knowledge about how Swift syntax worked, that would be amazing. That's a free idea for anybody who's watching or listening to

[00:34:21] Chris Eidhof (guest): that would be

[00:34:22] Leo Dion (host): because Yeah. Yeah. So yeah, definitely if you want a good VM app, you want bushel. If you want not that great. I try Virtual Buddy, but.

[00:34:33] Chris Eidhof (guest): I, I've not I'm sorry. I haven't used bushel yet, so I'll put in a good word for a virtual body and I also use, yeah, more comp competitors, but

[00:34:43] Leo Dion (host): Yeah. Yeah. What was I gonna say? So the other, the only other thing I had from SwiftUI this year was scroll position. Is that what's your opinion on that? I know a lot of people wanted it. Is it that helpful?

[00:34:55] Chris Eidhof (guest): Yeah, I think we could like if you know the tricks, you could do a lot of that stuff already. And so I think it's just nice that they made this a lot simpler. Like I think I. Scroll views are for me, like almost like the thing that, that makes iPhone, iPhone and like being able to work with those effectively is very necessary.

[00:35:16] Chris Eidhof (guest): And I think, I don't think people need to resort to these weird hacks that we've been doing to make, like reading the scroll position and setting the scroll position, like all of that, I think. These are big quality of life improvements that, that were necessary. And I think there's still a whole bunch more, right?

[00:35:34] Chris Eidhof (guest): Like in UIKit, we could do so many more things that we could now do in SwiftUI and I think there's like this whole backlog of things that the SwiftUI team needs to do. But I'm also very happy that well. Like I, I'd rather have it today than tomorrow. But I'm really happy that they take their time to find like the proper APIs and all of that.

[00:36:01] Leo Dion (host): Yes. Yeah.

[00:36:02] Chris Eidhof (guest): I'd rather have the feature and maybe a little bit later and then have it done well than rush it out. At least that's what it feels like to me. Other people might have a different opinion there

[00:36:14] Is SwiftUI Production Ready?
---

[00:36:14] Leo Dion (host): mara had a really good talk at Swift Heroes when I was there last year about building is SwiftUI prediction. Production ready. And one of the things that he had in his slide was some of the crazy names for methods and in UIKit and how like.

[00:36:33] Leo Dion (host): Like you're talking about taking your time. Like with UIKit, there is some really wild names for like methods. I'll post a link to the video, but it's pretty hilarious. And like thankfully they're not taking that approach with Swift. They're

[00:36:48] Chris Eidhof (guest): No, I.

[00:36:49] Leo Dion (host): there's a lot of benefits to that.

[00:36:52] Chris Eidhof (guest): Yeah, and like the whole production ready is also like a big topic, right? There's still people going out today complaining about this and I think, if I am personally, I'm much faster with SwiftUI, and yes, there are things that I cannot do today, but that's okay. I can always drop down to UI iki or App Kit and like the iteration speed that you get is amazing.

[00:37:13] Chris Eidhof (guest): The weird thing to me about Swift Joy is that. I, it, you could you move along and then you hit a roadblock and you conquer it and then you go and then you continue. And then sometimes the roadblocks are a little bit bigger and with swift eye it feels like you're moving along much quicker.

[00:37:27] Chris Eidhof (guest): But then when you do hit a roadblock, it's like a massive brake wall. And it's a bit harder to climb

[00:37:33] Leo Dion (host): percent.

[00:37:34] Chris Eidhof (guest): yeah. That's like a big difference. If it doesn't really do what you want it to do, then it can be definitely a bigger challenge.

[00:37:42] Leo Dion (host): I do wanna talk about that a bit, which is, you mentioned dropping down to UIKit. How does that affect the layout system and working within the framework of SwiftUI? Because we all have to do it at some point. Or AppKit, in my case.

[00:37:58] Chris Eidhof (guest): yeah, I think it's it's quite similar. Now we can, for our representable, we can use, also something we can implement size that fits, I think, if I'm not mistaken. And there we can basically write our own logic. I can quickly look it up, but there we can write our own. Yeah, you can implement size that fits for a view, and then you can write whatever logic you want.

[00:38:21] Chris Eidhof (guest): You could query your UI view, you could write your own logic there, or. Whatever you think is necessary. And it used to be possible also before size it fits was public. So you, and like I, there was I think an underscored method that would let you do this.

[00:38:39] Leo Dion (host): Okay. Okay. Speaking of underscore methods, have you used any of the print changes stuff to track like your views being redrawn? Do you know what I'm talking about?

[00:38:49] Chris Eidhof (guest): Yeah. Yeah. No that's necessary. And like the self that underscore print changes is what you mean, right? Yeah, I've used that. I don't use it that often. Like I, I typically write my views. I think I know why they re-render I'll add print statements a lot to see if that's true, but like

[00:39:08] Leo Dion (host): that there is more to do with how the data changes underneath and how it then triggers a redraw. It's not necessarily a layout thing, right?

[00:39:18] Chris Eidhof (guest): Exactly. Yeah. This is only about tracking why why you view re renders.

[00:39:23] Leo Dion (host): right.

[00:39:23] Chris Eidhof (guest): And yeah, no I use that. The other underscored methods I would, I, I used to use were the very views ones, but that's what we now get with group sub views and for each sub. And other than that I'm a little bit afraid to use too much like private stuff only maybe to understand how things work.

[00:39:44] Chris Eidhof (guest): And maybe one cool thing that people can do if you wanna know more about SWIFT ai is you can actually, in the terminal, you can CD into your Xcode app, and then you can find the SWIFT interface file for SwiftUI. So you could do like a find. Command and find like a file called SwiftUI. And then the SWIFT interface file for that framework.

[00:40:05] Chris Eidhof (guest): And it'll show you a lot of the internal stuff of how SwiftUI works. And you could see even implementations of certain methods and properties. So if that method has been marked as inline. It'll have the entire implementation in that SWIFT interface file. Which is very interesting.

[00:40:26] Chris Eidhof (guest): And so one of the things you could see there, for example, if you do dot border, call it a red, that's actually implemented as an overlay with a rectangle. With a

[00:40:35] Leo Dion (host): Oh really? That's awesome. Okay. That makes total sense.

[00:40:40] Chris Eidhof (guest): it does. Yeah. But once you get it right and it, nah.

[00:40:44] Leo Dion (host): Yeah. Chris, was there anything else you wanted to talk about before we close out?

[00:40:48] Chris Eidhof (guest): No. Thanks for having me. And yeah, if people are interested, check out the Swift Drive Field Guide or any of our books or if yeah. And I hope that's helpful. If you, if anybody listens and has questions about these things, let me know. I'm easy to find. And my email address is easy to find and then yeah.

[00:41:09] Leo Dion (host): Cool. Thank you so much, Chris. You're Chris at M dot ob objective, COBG bjc.io. We'll have legs to all your stuff in the show notes. Thank you again. This was fantastic. It's been awesome. People can. My peop people can find me on Twitter at Leo g Dion. Leo g Dion at. Ma on if you are, my company name is Break Digit. If you're looking for help with any of your apps reach out to me. I would love to see what we can do for you. If you're watching this on YouTube, and subscribe. If you are listening to this on a podcast player, please put in a review. If there's something you want to hear about, reach out to me.

[00:41:51] Leo Dion (host): If you wanna come on and be a guest, I would love to have you on. Thank you everybody and have a good rest of your day. Bye.

[00:41:58] Chris Eidhof (guest): Hi.