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.
Thank you so much, and I hope you enjoy the rest of today's episode.
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.
Chris Eidhof (guest): Thank you.
Thank you for having me.
So great.
Leo Dion (host): For people who don't know who you are, I'll let
you go ahead and introduce yourself.
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.
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.
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?
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.
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.
And so the combination was perfect because we could just write stuff and
he'd be like, oh no, this is all wrong.
Leo Dion (host): Yeah.
Chris Eidhof (guest): And that's how you learn.
Leo Dion (host): yeah.
That's awesome.
What are you, what's your native language?
Chris Eidhof (guest): Dutch.
Yeah.
Which is the same as German almost.
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
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.
They're loss.
Leo Dion (host): Yeah, exactly.
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.
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.
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.
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.
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.
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.
Leo Dion (host): When it comes to the field guide, so is the field guide
completely free for anyone to consume?
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.
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
Leo Dion (host): that makes total sense.
So what do people not know about the layout system that they should know?
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.
Like you can try maybe a fixed size or one of these things,
Leo Dion (host): geometry
Chris Eidhof (guest): to reader.
Leo Dion (host): and fixes everything.
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.
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?
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.
Leo Dion (host): When did it click for you that you were like I get this,
Chris Eidhof (guest): Oh,
Leo Dion (host): how to communicate this to other people.
Chris Eidhof (guest): there is no one moment.
Leo Dion (host): Okay.
Okay.
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.
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?
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.
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?
Chris Eidhof (guest): Yeah,
Leo Dion (host): So UIKit, like obviously, but like what else have
you were, did you do besides that
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.
And and then and then I went to university and there it was super
hascal heavy and that really.
Leo Dion (host): interesting.
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?
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.
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.
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.
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.
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
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.
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.
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.
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.
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.
But yeah, it would be interesting to see like them actually pull the rug
out and be like, everything's down.
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,
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.
Chris Eidhof (guest): Yeah.
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?
Chris Eidhof (guest): Yes.
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.
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?
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.
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.
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?
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
Leo Dion (host): Yeah, I would imagine yes.
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.
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.
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
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.
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
It's really fun.
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?
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.
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
Chris Eidhof (guest): or not even UIKit, like a rectangle or a text.
I don't think that's UIKit anymore.
It's just,
Leo Dion (host): Oh, okay.
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.
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.
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.
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.
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,
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?
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.
So the,
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.
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.
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.
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.
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.
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?
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
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.
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.
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.
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.
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.
Chris Eidhof (guest): Yeah.
No, yeah that's a thing for sure.
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?
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
Leo Dion (host): right, you told me this.
Okay, go ahead.
Sorry.
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.
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.
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
Leo Dion (host): That's funny.
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.
Like all the animations.
It's all my fake Swift J implementation.
Leo Dion (host): That's amazing.
That's awesome.
Yeah.
Let's get into it.
Besides view collections, what else was your favorite thing from dubbed
up this year concerning swifty y.
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
Leo Dion (host): the gradients.
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.
I think everybody was on Twitter, was writing mesh
gradient editors immediately.
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
Chris Eidhof (guest): Maybe, I don't know.
I think
Leo Dion (host): Okay.
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
Leo Dion (host): makes a big difference.
Yeah.
Chris Eidhof (guest): it makes a big difference.
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.
Leo Dion (host): Have you done anything with metal or have you
even have the desire to Okay.
Because that stuff gets in right.
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.
Leo Dion (host): I don't miss that stuff.
Chris Eidhof (guest): I would want to understand it better, but I don't.
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?
Chris Eidhof (guest): I know I've not owned an iPad for, what is it, 10 years
Leo Dion (host): Yeah.
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
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.
Chris Eidhof (guest): Yeah.
I think,
Leo Dion (host): yeah, go ahead.
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.
Leo Dion (host): You mean entries?
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.
Like it's so much work to type in an environment key.
Leo Dion (host): There's so much in bushel, there
is so much boilerplate code
Chris Eidhof (guest): I know.
Yeah.
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.
I guess could I use it?
Chris Eidhof (guest): I think you could.
Yeah, I
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.
Chris Eidhof (guest): Yeah.
And even if you couldn't, you could write your own macro
and do your own version of it.
Leo Dion (host): Exactly.
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.
Leo Dion (host): It is really hard.
Swift and Texas is really hard.
Yeah, I agree.
But that's a perfect one, like you said,
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.
And.
Leo Dion (host): right.
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.
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,
Chris Eidhof (guest): Oh yeah.
Leo Dion (host): that looks awesome.
I still have issues with trying to get previews to work half the time, but
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.
That's easy to unit test, where
Leo Dion (host): Yeah,
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.
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
Chris Eidhof (guest): Exactly.
Yeah.
Leo Dion (host): did you do, have you done any widget stuff?
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
Leo Dion (host): update and having him inter, because you can
interact with him at least since the last version, I wanna say.
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,
Leo Dion (host): Oh my gosh.
Not even a photo of your kids.
Come on.
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.
Leo Dion (host): gosh.
Okay.
We should cut that out.
That's so embarrassing.
Chris Eidhof (guest): Get it set up tonight.
Leo Dion (host): You're still on iOS 16 or 16?
Yes.
17.
I always get confused.
There's so many.
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
Leo Dion (host): Oh, that makes sense.
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.
And I, it was it worked super smoothly.
It's absolutely worth it.
We should link to that in the show notes
Leo Dion (host): No, we should link to Bushel.
Why would I wanna link to Virtual Buddy?
Chris Eidhof (guest): Oh, sorry.
Leo Dion (host): Oh my gosh, Chris.
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.
Leo Dion (host): oh yeah.
'cause okay, that makes sense.
Yeah.
It's cool.
It's fine.
Chris Eidhof (guest): I've, so I've
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.
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
Leo Dion (host): If you've been doing TypeScript Yeah, exactly.
It is totally awesome.
Yeah.
So I build web front ends for my apps and we use, I use TypeScript
and it's awesome that CSS HT ML.
Chris Eidhof (guest): Yeah.
Leo Dion (host): that's the, that is Chris, you're gonna, you're
gonna be disappointed with the
Chris Eidhof (guest): Okay.
Yeah.
Let's see.
Leo Dion (host): to copilot, copilot is much better.
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.
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.
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.
Leo Dion (host): That's amazing.
Yeah.
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.
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
Chris Eidhof (guest): that would be
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.
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
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?
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.
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?
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.
Leo Dion (host): Yes.
Yeah.
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
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.
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
Chris Eidhof (guest): No, I.
Leo Dion (host): there's a lot of benefits to that.
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.
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.
But then when you do hit a roadblock, it's like a massive brake wall.
And it's a bit harder to climb
Leo Dion (host): percent.
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.
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.
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.
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.
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?
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
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?
Chris Eidhof (guest): Exactly.
Yeah.
This is only about tracking why why you view re renders.
Leo Dion (host): right.
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.
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.
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.
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
Leo Dion (host): Oh really?
That's awesome.
Okay.
That makes total sense.
Chris Eidhof (guest): it does.
Yeah.
But once you get it right and it, nah.
Leo Dion (host): Yeah.
Chris, was there anything else you wanted to talk
about before we close out?
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.
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.
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.
Chris Eidhof (guest): Hi.