Empower Apps

Daniel Steinberg comes in the podcast to talk about his latest book on Swift Testing as well as the state of Swift development in 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) - What is Swift Testing
  • (10:04) - Benefits of Swift Testing
  • (17:22) - Parameterized Tests
  • (20:30) - Swift 6
  • (24:47) - WWDC 2024
  • (31:20) - Swift Data
  • (35:10) - Swift Data 🙃 Sendable
  • (37:02) - Swift Macros
  • (41:44) - Books and Conferences
Thanks to our monthly supporters
  • 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
Daniel Steinberg
Dad, husband, and storyteller...Podcaster,writer and editor.

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] What is Swift Testing
---

[00:00:00] ​

[00:00:00] Leo Dion (host): Hey folks. I'm trying to get these episodes out as soon as I can. Here's another great episode I did recently with Daniel on his new book, the Case of The Crimson Test Suite and Swift Testing. Hope you enjoy it. I'm really excited about going to. Server site Swift at the end of September. Daniel will be there too.

[00:00:21] Leo Dion (host): He's given a great talk on macros. I if you're gonna be in the area, I highly recommend checking it out. There's a discount code EMPOWERAPPS, all caps, one word. If you put that in, you'll get 15% off. So definitely check that out. I'll put that in the show notes as well. Thank you and I hope you enjoy this episode.

[00:00:41] Leo Dion (host): Bye everybody. Welcome to another episode of Empower Apps. I'm your host, Leo Dion. Today I'm joined with Daniel Steinberg. Daniel, thank you so much for coming on.

[00:00:54] Daniel Steinberg (guest): My pleasure.

[00:00:55] Leo Dion (host): This is second time you've been on the podcast and

[00:00:58] Daniel Steinberg (guest): time. I think we talked about functional

[00:01:01] Leo Dion (host): we did.

[00:01:02] Leo Dion (host): We did. Yeah. Well, before we jump in, I'll let you go

[00:01:05] Leo Dion (host): ahead and introduce yourself.

[00:01:09] Daniel Steinberg (guest): Okay. I know a lot of you, I see a lot of you, at conferences.

[00:01:12] Daniel Steinberg (guest): I tend to write books and do contract coding and

[00:01:16] Daniel Steinberg (guest): teaching both at conferences and privately

[00:01:19] Daniel Steinberg (guest): on iOS and Mac OS topics.

[00:01:22] Leo Dion (host): Speaking of functional programming, where do you think that is right now? In a somewhat post combined world?

[00:01:30] Daniel Steinberg (guest): That's a good question. In some ways we're seeing more of it in Apple APIs. You're seeing maps and filters and things all over

[00:01:37] Daniel Steinberg (guest): the place. You still see them in, for instance, async

[00:01:40] Daniel Steinberg (guest): sequences. So you still see a lot of the things we did in combine have surfaced in other

[00:01:46] Daniel Steinberg (guest): places. So.

[00:01:49] Daniel Steinberg (guest): I think we came to terms with the fact that as we knew Swift wasn't

[00:01:53] Daniel Steinberg (guest): really a functional language, but we could do functional things with it, and I still like to code that

[00:01:58] Daniel Steinberg (guest): way a lot.

[00:01:58] Leo Dion (host): Yeah, same here. Yeah, that's a good point. I feel like if anything, we still have, I mean, combine's still around obviously, but if there's anything we still have from That is a lot of you can see traces of it and the way. Functional programming is everywhere with anything new that comes out, including the async sequence stuff. so yeah, that's

[00:02:17] Daniel Steinberg (guest): of the problems

[00:02:18] Daniel Steinberg (guest): though, is that, you know, functional programming works best with

[00:02:22] Daniel Steinberg (guest): value types, and we've got that emphasis to use value types and value tips work best with async and all that. Yet,

[00:02:30] Daniel Steinberg (guest): Swift UI is pushing us to use more reference types on the backend

[00:02:35] Daniel Steinberg (guest): for observable and for Swift Data and things like that.

[00:02:38] Daniel Steinberg (guest): So it's a bit of a mixed message between Swift and Swift UI. And so with Swift, it's a, it's easy to use.

[00:02:45] Daniel Steinberg (guest): Functional with

[00:02:46] Daniel Steinberg (guest): Swift UI, it's a little harder.

[00:02:48] Leo Dion (host): Yeah. Yeah, that's true. That's a really good point. Yeah, and on top of it we have like, non copyable types, which is a whole other like, Pandora's box.

[00:02:58] Daniel Steinberg (guest): Understand them yet, so.

[00:03:03] Leo Dion (host): that makes two of us. Okay, so today we're gonna talk about Swift testing kinda I guess give the overview of Swift testing, what it offers, alternative to XC testing, and what have you liked, what have you disliked about it I guess.

[00:03:20] Daniel Steinberg (guest): That's a lot. So the first thing is what attracted me to it. Every once in a while something gets released

[00:03:28] Daniel Steinberg (guest): and it just feels like something I want to get involved

[00:03:31] Daniel Steinberg (guest): in. I wanna write a book about, I want to understand it

[00:03:34] Daniel Steinberg (guest): better. And Swift testing. Not only did I like the

[00:03:38] Daniel Steinberg (guest): APIs, but the way the

[00:03:39] Daniel Steinberg (guest): team has. Work through the process, the support they've given the community through docs.

[00:03:46] Daniel Steinberg (guest): It's just been

[00:03:46] Daniel Steinberg (guest): really,

[00:03:48] Daniel Steinberg (guest): I

[00:03:48] Daniel Steinberg (guest): think a model

[00:03:49] Daniel Steinberg (guest): project from Apple. And so it's been nice to see

[00:03:52] Leo Dion (host): What I think, and I'm gonna, I'm gonna just say I'm ignorant, but what does SW.

[00:03:57] Daniel Steinberg (guest): even after I've written a book. I.

[00:04:01] Leo Dion (host): I went into the videos and I'm like, okay, what is this offer that XC testing has? And I do the fact that it's pure Swift for a hundred reasons, but

[00:04:10] Leo Dion (host): I'm not sure it offers, what is it offer that XC

[00:04:13] Leo Dion (host): testing doesn't already offer outside of the fact that it's not tied to Objective-C.

[00:04:20] Daniel Steinberg (guest): So I don't know if you remember when Steve Jobs came back

[00:04:25] Daniel Steinberg (guest): to Apple. When Steve Jobs came back

[00:04:27] Daniel Steinberg (guest): to Apple, there were all sorts of

[00:04:30] Daniel Steinberg (guest): devices that Apple was selling all sorts of Macs, and Steve said, no, we're gonna simplify the line.

[00:04:37] Daniel Steinberg (guest): We have pro, we have consumer, we have laptop, we

[00:04:39] Daniel Steinberg (guest): have desktop. And in my view, that's one of the biggest things that Swift testing brings is it says, we're gonna simplify.

[00:04:47] Daniel Steinberg (guest): There's not a thousand XCT asserts. You

[00:04:50] Daniel Steinberg (guest): have to know. You set things up and then you either expect a result. You require

[00:04:56] Daniel Steinberg (guest): a

[00:04:56] Daniel Steinberg (guest): result. And then, so that's the one axis. And then the other axis is if you expect it to succeed, that's great. If you expect it to throw an error, there's an expect throws or

[00:05:07] Daniel Steinberg (guest): require throws.

[00:05:08] Daniel Steinberg (guest): And so the expectations to begin with are so much easier to work with.

[00:05:14] Leo Dion (host): Well, let's talk about that a little bit. What do you when you say expectations, are we talking about from what. I remember with XC test is like you basically have the ability to wait for an expectation. If you have something that gets called an closure, for instance, is that what we're talking about when we say expectations?

[00:05:30] Daniel Steinberg (guest): No, the ex expectation that I'm talking

[00:05:32] Daniel Steinberg (guest): about is the equivalent of the

[00:05:34] Daniel Steinberg (guest): XCT assert true XCT assert equal XCT, all of those. And so instead of that, we have

[00:05:41] Daniel Steinberg (guest): a pound expect. The pound expect accepts a Boolean where you say, this thing

[00:05:47] Daniel Steinberg (guest): equals this thing. And so,

[00:05:50] Daniel Steinberg (guest): Everything in Swift testing is a macro, the at test that decorates the method or the function is a macro.

[00:05:58] Daniel Steinberg (guest): And the pound expect is also a macro. The

[00:06:00] Daniel Steinberg (guest): attest is an attached macro, excuse me. That decorates the method that it modifies that it's attached to, and the pound expect is one of those freestanding

[00:06:11] Daniel Steinberg (guest): macros that expands into all the things that we need. So there's a lot less ceremony, which is kind of nice.

[00:06:18] Leo Dion (host): Yeah, that you could definitely say that. What. What, if somebody wants to jump into it, what's the first thing that they may be overwhelmed by? Or that they may feel intimidated by, that you think helped you get into Swift testing?

[00:06:34] Daniel Steinberg (guest): Well, actually what

[00:06:37] Daniel Steinberg (guest): made it harder for me and for those of us that looked at it right away was it wasn't integrated in X code and we had to

[00:06:45] Daniel Steinberg (guest): do things to make it work. All that is gone with Xcode

[00:06:48] Daniel Steinberg (guest): 16. What made it hard from the command line with Swift packages was we had to add a flag to Swift test to make it

[00:06:55] Daniel Steinberg (guest): work That's gone with Xcode

[00:06:57] Daniel Steinberg (guest): 16 beta five.

[00:06:59] Leo Dion (host): Okay.

[00:07:00] Daniel Steinberg (guest): a lot of the things that made it hard to get

[00:07:02] Daniel Steinberg (guest): Your feet wet with are gone, and that's really nice. As for writing your own tests,

[00:07:08] Daniel Steinberg (guest): it depends on if you're coming from

[00:07:10] Daniel Steinberg (guest): XC test or not. If you're coming from XC test. Then you're used to creating some class that subclasses from something, and then you have to write the name of the methods a specific way and things execute a specific

[00:07:25] Daniel Steinberg (guest): way.

[00:07:26] Daniel Steinberg (guest): And so one of the things that might surprise you is

[00:07:28] Daniel Steinberg (guest): your first test can just be a free function. It doesn't have to be part of a

[00:07:32] Daniel Steinberg (guest): structure class or anything.

[00:07:35] Leo Dion (host): Do you think that do you think it's gonna be easier to like, organize tests and make them a little bit more readable? In Swift testing. That's the biggest benefit I've seen.

[00:07:45] Daniel Steinberg (guest): Well, so the Swift testing team has given us several axes to do that with. So if you have a

[00:07:52] Daniel Steinberg (guest): test, you can name it anything you want. I tend to prefer T names. Then if you want to see a more descriptive name, when you run the

[00:08:01] Daniel Steinberg (guest): test, you have the freedom to create a display name. So in the AT test, one of the arguments is how do you want this to appear?

[00:08:08] Daniel Steinberg (guest): And that's a display name is a string.

[00:08:10] Daniel Steinberg (guest): And then you say, well, I've got this test here and this test here, and this test

[00:08:14] Daniel Steinberg (guest): here that I want to group somehow. Do they have a common reason for being I can create a tag and now I can run all the things with a

[00:08:21] Daniel Steinberg (guest): common tag? Do all these

[00:08:23] Daniel Steinberg (guest): things belong together conceptually and

[00:08:26] Daniel Steinberg (guest): hierarchically, and I want to use the same setup for them.

[00:08:30] Daniel Steinberg (guest): I create a

[00:08:31] Daniel Steinberg (guest): struct, which is a

[00:08:32] Daniel Steinberg (guest): suite, and I can name that suite

[00:08:35] Daniel Steinberg (guest): and I can provide different things there. And so there's all these ways of organizing your tests that are very

[00:08:41] Daniel Steinberg (guest): handy.

[00:08:41] Leo Dion (host): How about, sorry, I'm trying to remember. How do you keep your tests organized? Are you doing like your just functions out in the main. File or are you setting up STRs or what do you suggest? If you wanna keep your test organized in a fashion and using your display name properly and stuff.

[00:09:03] Daniel Steinberg (guest): So I use a mix. Some tests can run on their own. Some

[00:09:07] Daniel Steinberg (guest): want to be organized into a suite. I almost always will use

[00:09:11] Daniel Steinberg (guest): tags. You can use which we didn't talk about yet. Suites within a suite. So one of the nice things is so I, if I'm building a calculator as I do in one of my running

[00:09:23] Daniel Steinberg (guest): examples and I have all these things that are testing the stack, but inside

[00:09:28] Daniel Steinberg (guest): of there are ones that test the stack and they also

[00:09:30] Daniel Steinberg (guest): test the display.

[00:09:31] Daniel Steinberg (guest): I might create a strt within a struct that does those, and now I can run those separately or altogether. The problems with Swift testing are generally not with Swift testing. They're limitations of

[00:09:44] Daniel Steinberg (guest): Swift. So, for example, if I

[00:09:47] Daniel Steinberg (guest): have a property in my outer struct and I want to view it from my inner struct, you can't.

[00:09:53] Daniel Steinberg (guest): And because we don't create the setup code, I can't even pass it in.

[00:09:58] Daniel Steinberg (guest): And so you do have to duplicate some of the setup if you're doing a struct within a struct.

[00:10:03] Leo Dion (host): Okay. Got it.

[00:10:04] Benefits of Swift Testing
---

[00:10:04] Leo Dion (host): What are some other benefits that you saw with Swift testing over XC test?

[00:10:11] Daniel Steinberg (guest): So one of the things is out of the box tests automatically run in parallel in random order. And so you don't

[00:10:19] Daniel Steinberg (guest): get these

[00:10:21] Daniel Steinberg (guest): issues where, oh, I didn't, expose that issue because my

[00:10:24] Daniel Steinberg (guest): tests always run in this order, and maybe I've

[00:10:28] Daniel Steinberg (guest): got some dependencies that I don't remember. On the

[00:10:32] Daniel Steinberg (guest): other hand, there are some tests that you might wanna run in a specific

[00:10:36] Daniel Steinberg (guest): order, and there's an easy flag, they call them traits that you can set that

[00:10:40] Daniel Steinberg (guest): says, run these as serializable. And so

[00:10:43] Daniel Steinberg (guest): that's a nice handy thing that you can do. Serializable.

[00:10:46] Daniel Steinberg (guest): Ones

[00:10:48] Daniel Steinberg (guest): one runs then the next, and

[00:10:50] Daniel Steinberg (guest): so that

[00:10:50] Daniel Steinberg (guest): might increase your time. You're not getting the parallel. The other thing is they play nice with

[00:10:55] Daniel Steinberg (guest): asic. So I can have async

[00:10:58] Daniel Steinberg (guest): tests and to your question from before, like I

[00:11:02] Daniel Steinberg (guest): can do an XC test, but so much easier.

[00:11:05] Daniel Steinberg (guest): I

[00:11:05] Daniel Steinberg (guest): can require that a test completes in some amount of

[00:11:08] Daniel Steinberg (guest): time.

[00:11:09] Leo Dion (host): Oh wow. Okay.

[00:11:11] Daniel Steinberg (guest): I don't wanna wait forever for

[00:11:12] Daniel Steinberg (guest): this, but I can run something that is actually

[00:11:14] Daniel Steinberg (guest): async.

[00:11:16] Leo Dion (host): That's awesome. Like the things, like I get frustrated with XY tests is, like you said, it's a lot of boiler plate code. Is there even like an idea of like setup and tear down? In Swift testing. Really, do you even need

[00:11:30] Daniel Steinberg (guest): You can, but what happens? For example, if I have a suite that contains four tests, what happens is. A separate instance of that suite of that struct is created for each of those tests and they are run separately. So you're not getting the cross-contamination there. I don't have to worry about the setup and the tear down there.

[00:11:52] Daniel Steinberg (guest): So maybe I have just an a knit for my struct if I need to set up fancy things, but for the most part, I'm just adding a property and giving it a value, and that's all the setup I need.

[00:12:05] Leo Dion (host): What so one of the things, you know, we had a question or comment in Twitter from someone behavior tree said. It needs in-source testing better snapshot serialization, where you can omit fields, content for dates, IDs, et cetera. One thing, yeah. That I've heard a lot of is just well that was one of the things

[00:12:26] Leo Dion (host): I was expecting is like the ability to do mocking, things like that, that are difficult to do

[00:12:33] Leo Dion (host): in SW Swift basically because

[00:12:36] Leo Dion (host): we don't have the dynamic abilities that we got in Objective-C. And I was looking forward to maybe some macros for that. Where do you see that

[00:12:43] Leo Dion (host): stance for things that people want? Do you think there's gonna be

[00:12:47] Leo Dion (host): kind of a

[00:12:48] Leo Dion (host): community around that, or do you think it's just not

[00:12:51] Leo Dion (host): something that's necessary as much as

[00:12:53] Leo Dion (host): people say it's.

[00:12:56] Daniel Steinberg (guest): I think both sides of that I think in general when something doesn't do something you want,

[00:13:01] Daniel Steinberg (guest): you can both

[00:13:02] Daniel Steinberg (guest): question that it doesn't do it, and you can question whether you really want and need it. Are you doing something that, that you need to do? There are some things that Swift testing

[00:13:12] Daniel Steinberg (guest): doesn't do yet, for example. it explicitly does not do performance testing. It explicitly does not do UI testing,

[00:13:20] Daniel Steinberg (guest): and so these are things that are excluded. The other thing is this is a first release, and as a

[00:13:26] Daniel Steinberg (guest): first release, I find it very robust.

[00:13:29] Daniel Steinberg (guest): In fact, it isn't even released yet. In a way

[00:13:32] Daniel Steinberg (guest): it's, you know, in September when Swiss six comes out that we'll see,

[00:13:37] Daniel Steinberg (guest): oh, now it's released.

[00:13:38] Daniel Steinberg (guest): So. There's a side of me that when

[00:13:40] Daniel Steinberg (guest): people complain, I just wanna say, come on people.

[00:13:45] Leo Dion (host): What if you were that was one thing.

[00:13:47] Leo Dion (host): I wanted to mention is that it is, it does require Swift six. Correct. And it's delivered as a Swift package, which is really great. It's like basically it's all open source, I would assume, right. So you

[00:13:58] Daniel Steinberg (guest): It is open source and you can

[00:14:00] Daniel Steinberg (guest): submit issues there. It's an apples.

[00:14:04] Daniel Steinberg (guest): It's an apple's repl repo on GitHub. The team is amazingly

[00:14:10] Daniel Steinberg (guest): responsive.

[00:14:11] Daniel Steinberg (guest): If you publish on social or you participate in the

[00:14:14] Daniel Steinberg (guest): forums. the team members have been just amazingly

[00:14:18] Daniel Steinberg (guest): responsive and

[00:14:19] Daniel Steinberg (guest): helpful.

[00:14:21] Leo Dion (host): Are they keeping it under the Apple organization or are they gonna move it to Swift by any Swift Lang by any chance?

[00:14:27] Daniel Steinberg (guest): I think it's on, or I

[00:14:29] Leo Dion (host): It is Swift Link. It is Swift

[00:14:31] Daniel Steinberg (guest): not there yet, they announced that it was going

[00:14:33] Daniel Steinberg (guest): to

[00:14:33] Daniel Steinberg (guest): be.

[00:14:33] Leo Dion (host): Yeah. No, it is right now as of the recording, so yeah. Yeah. That's awesome. Definitely check that out. Really great documentation here. One other thing.

[00:14:42] Leo Dion (host): So do you think what other things do you think are missing that you think the community could use in Swift testing that. Either you could use additional or you feel missing from XXI testing.

[00:14:55] Daniel Steinberg (guest): What I've, what I found a lot of with my early experiments with Swift testing is if something isn't behaving, it's often something the team knows too. So I'll give you a fun example. I'm writing the book

[00:15:10] Daniel Steinberg (guest): and I have this example where I'm serializing. The whole reason I'm serializing is just to demo this thing that they have.

[00:15:17] Daniel Steinberg (guest): Generally, you don't wanna serialize your tests. You want 'em to run in random order,

[00:15:21] Leo Dion (host): Right.

[00:15:22] Daniel Steinberg (guest): and they're failing. They're not running in random order, but they're not running in the order

[00:15:28] Daniel Steinberg (guest): I expect. And so they're running first and third, and all of a sudden, I realize they're running in alphabetical order of the method name.

[00:15:37] Daniel Steinberg (guest): But it turns out the team already knows that. They fixed it and in the next release there it was,

[00:15:43] Daniel Steinberg (guest): in fact, they'd known it before I'd encountered it. It just hadn't made its way through the release cycle. So sometimes these things that we run

[00:15:50] Daniel Steinberg (guest): into, it's not a limitation of the framework, it's that sometimes things aren't correctly implemented yet the things they've thought about are deep.

[00:16:01] Daniel Steinberg (guest): Now there are some

[00:16:02] Daniel Steinberg (guest): lacking and there's good reasons for the lacking. So I don't know, have you worked with Swift macros at all?

[00:16:08] Leo Dion (host): Yes, I've written one Swift macro.

[00:16:11] Daniel Steinberg (guest): So one of the nice things about Swift macros is you can create tests for them and they have a really nice test template for XC tests where you can say, here's what I typed in, here's what I

[00:16:24] Daniel Steinberg (guest): expected to expand to, and even if something fails, here's how I expect it to fail.

[00:16:31] Daniel Steinberg (guest): There's an issue with, Swift testing with that because

[00:16:35] Daniel Steinberg (guest): you can't get a cyclic dependency to have things work

[00:16:39] Daniel Steinberg (guest): out so you can make it work with Swift testing.

[00:16:42] Daniel Steinberg (guest): I am, excuse me,

[00:16:45] Daniel Steinberg (guest): I am updating the macros book to accommodate that, but

[00:16:50] Daniel Steinberg (guest): It's, we're all encountering this together and so I don't know if you remember the early days of Swift UI. But part of it was a lot of engineers internal at Apple weren't using this thing in anger, and so they weren't

[00:17:04] Daniel Steinberg (guest): realizing what needed to change about it.

[00:17:06] Daniel Steinberg (guest): And you saw in Swift two and three as they started using it internally, they said, oh, you guys were right about the navigation view. It needs to be something stronger. And now we get a navigation stack. I think the same thing will happen with Swift testing as

[00:17:20] Daniel Steinberg (guest): more internal

[00:17:21] Daniel Steinberg (guest): people use it.

[00:17:22] Parameterized Tests
---

[00:17:22] Leo Dion (host): One thing we didn't mention and I think is a huge benefit of Swift testing is like the data driven stuff where you can set up. Series of and say these should equal, these should result into these, you know, you know what I'm talking about. I'm not sure the exact

[00:17:38] Daniel Steinberg (guest): I think what you mean more is the testing

[00:17:42] Leo Dion (host): Yes, that's exactly what I mean.

[00:17:43] Leo Dion (host): Thank you, Daniel.

[00:17:44] Daniel Steinberg (guest): for.

[00:17:48] Daniel Steinberg (guest): you know, five tests that essentially do the same thing, but each one takes a different piece of input. You can say, okay, here's these pieces of input. Put 'em in an array and say that this test depends on these arguments, and now it'll run them. And what it does is very clever. This single test will create five instances of the test, one for each of the inputs.

[00:18:12] Daniel Steinberg (guest): So if one fails, you can see it.

[00:18:15] Daniel Steinberg (guest): You can see what went wrong. You can fix the issue, run the wrong tests first, and then run all the tests to make sure it's fixed for all of them. The other thing is, say you have two axes and so you want two arrays. And so if I have two arrays, what it'll do is it'll create tests for each combination.

[00:18:34] Daniel Steinberg (guest): And so if I have five in the first array and four in the second,

[00:18:38] Daniel Steinberg (guest): I get 20 tests.

[00:18:40] Daniel Steinberg (guest): Now, that's the limitation,

[00:18:42] Daniel Steinberg (guest): unfortunately. I can't put in a third array. So the limitation is two arrays, and at least at this point, the warning, if you put in a third array doesn't say that's what you've done wrong.

[00:18:54] Daniel Steinberg (guest): It's calling out something else. But if you try two more than two arrays,

[00:19:00] Daniel Steinberg (guest): but you can get clever and you can zip two together, or you can group them differently or have an array of tuple if you

[00:19:07] Daniel Steinberg (guest): want.

[00:19:09] Daniel Steinberg (guest): So there's many ways around it. I don't find it a deep limitation. Again if you're wanting to do more than two arrays,

[00:19:17] Daniel Steinberg (guest): you may need to ask, do I really need

[00:19:20] Daniel Steinberg (guest): to, or is there another way to look at

[00:19:21] Daniel Steinberg (guest): it? And what they're trying to prevent is, it's so easy for us to feed in so many arrays and now we've got an explosion of tests. And often there's so

[00:19:30] Daniel Steinberg (guest): much redundancy that why are you taxing the system

[00:19:33] Daniel Steinberg (guest): like that?

[00:19:34] Leo Dion (host): Yeah. Yeah, that's a fair point. If you were gonna start a project, let's say you're gonna do an app, would you go with Swift

[00:19:41] Leo Dion (host): testing or would you go with Ixy test?

[00:19:44] Daniel Steinberg (guest): I would go with Swift testing, but I

[00:19:46] Daniel Steinberg (guest): tend to do almost no UI testing. My, my UI layer is very thin, and so if I've really tested the model and what I still call the controller layer, you know, the view model, the presenter, whatever you call

[00:20:00] Daniel Steinberg (guest): it, if I've really

[00:20:01] Daniel Steinberg (guest): tested those properly. Then the connection of the UI to those

[00:20:06] Daniel Steinberg (guest): I don't really

[00:20:07] Daniel Steinberg (guest): test that much, but if you've seen my apps, the designs aren't pretty.

[00:20:11] Daniel Steinberg (guest): And so I'm not looking at screenshots

[00:20:13] Daniel Steinberg (guest): to see if,

[00:20:14] Daniel Steinberg (guest): Things look right. In fact, I will

[00:20:16] Daniel Steinberg (guest): say thank goodness for tech reviewers In a previous example of my calculator app, I had no four and five

[00:20:24] Daniel Steinberg (guest): buttons. I had two, two and three buttons. So.

[00:20:30] Swift 6
---

[00:20:30] Leo Dion (host): Nice. And so you would go it require, but it requires Swift six, right? So if you're, you have to use X code 16 basically, if you're gonna do Swift testing. right?

[00:20:41] Daniel Steinberg (guest): But if I'm creating a new project, that's what I'm gonna do. You said if I'm creating a new app, what would I do? The other thing is if I'm creating a new package.

[00:20:52] Daniel Steinberg (guest): I would absolutely

[00:20:53] Daniel Steinberg (guest): do it in Swift six. cause one of the nice things in Swift six

[00:20:56] Daniel Steinberg (guest): is you can mix Swiss five and Swift six packages. So if I'm creating a new package, I do it in Swift six, I use Swift testing and I'm not doing much UI in a package anyway,

[00:21:08] Daniel Steinberg (guest): so

[00:21:09] Daniel Steinberg (guest): I'm feeling pretty good about that.

[00:21:11] Daniel Steinberg (guest): And one of the really

[00:21:12] Daniel Steinberg (guest): nice things Apple did with this transition to Swift six is

[00:21:15] Daniel Steinberg (guest): package by package. They can be Swift five, Swift six, and everything works well together.

[00:21:19] Leo Dion (host): Yep. Yeah. That's awesome.

[00:21:22] Daniel Steinberg (guest): I know I sound like such a fan boy

[00:21:25] Leo Dion (host): with Swift six or Swift testing?

[00:21:27] Daniel Steinberg (guest): with all of it.

[00:21:29] Leo Dion (host): I know, I mean, yeah, so sw, so ga, you would totally go on board with Swift testing. As far as moving forward, there's nothing you miss from XC test at all.

[00:21:40] Daniel Steinberg (guest): so I was a fan of behavior driven development, not test driven development. And that's the given when then

[00:21:47] Daniel Steinberg (guest): type

[00:21:47] Daniel Steinberg (guest): of setting. And so years ago I'd like the sort of the kiwi, the

[00:21:52] Daniel Steinberg (guest): cucumber type of testing frameworks, XY test. Was

[00:21:58] Daniel Steinberg (guest): kind of like a port

[00:22:01] Daniel Steinberg (guest): of the old J unit, not even what J Unit

[00:22:03] Daniel Steinberg (guest): has become.

[00:22:05] Leo Dion (host): That's a

[00:22:05] Daniel Steinberg (guest): other thing is, yes,

[00:22:08] Leo Dion (host): Okay.

[00:22:09] Daniel Steinberg (guest): And, so the other thing is that Xcode, as much as I really like Xcode. There's

[00:22:16] Daniel Steinberg (guest): some things that Xcode has never done that makes testing much easier. So for instance, IntelliJ for I think 20 years since the old Java days

[00:22:26] Daniel Steinberg (guest): when they were first getting started, had this thing where in a test, if you said, I want to test that this class has this

[00:22:35] Daniel Steinberg (guest): method and it didn't have this method, Intej would say, well, do you want me to stub it out for you?

[00:22:40] Daniel Steinberg (guest): There's no reason that Swift, which is strongly typed, and

[00:22:45] Daniel Steinberg (guest): Xcode can't do that for us now, but it doesn't, and that makes testing so much easier if you can, if you really want to do TDD and drive your development

[00:22:55] Daniel Steinberg (guest): with tests. And so I tend to do more test my things as I create 'em. I don't drive

[00:23:01] Daniel Steinberg (guest): it. But one of the key features of

[00:23:05] Daniel Steinberg (guest): testing for me is not that I'm

[00:23:08] Daniel Steinberg (guest): testing the app. I'm writing

[00:23:10] Daniel Steinberg (guest): API that consumes

[00:23:12] Daniel Steinberg (guest): the thing that I'm creating. And so it's the first code that I write that consumes this new thing that I, so I can look and go, well,

[00:23:19] Daniel Steinberg (guest): I don't know, like the way I call that method,

[00:23:22] Daniel Steinberg (guest): I'm calling it from a test. But what it means is then I go in

[00:23:25] Daniel Steinberg (guest): and I change the way I call that method.

[00:23:27] Daniel Steinberg (guest): I change its name.

[00:23:28] Daniel Steinberg (guest): I change its parameters.

[00:23:30] Daniel Steinberg (guest): I make a, an invisible label

[00:23:32] Daniel Steinberg (guest): so that I'm not having to call a label

[00:23:34] Daniel Steinberg (guest): colon, whatever. And so to me, one of the big benefits of testing is design.

[00:23:41] Leo Dion (host): I agree with that a hundred percent. Yeah. because it's inter you're testing the interface, but it's like the interface of the code, right? Like it's not it's like now you get to see it in actual use and you're like, yeah, I don't like how that looks. And yeah, that makes total, I like that analogy a lot.

[00:23:58] Daniel Steinberg (guest): One of the things I like

[00:23:59] Daniel Steinberg (guest): is with packages, you can also run it from the command line and the reports you get in the command line are really nice. So one of the limitations was, I said

[00:24:08] Daniel Steinberg (guest): before, if you tag something, you can run just the tags.

[00:24:13] Daniel Steinberg (guest): Currently, you can

[00:24:13] Daniel Steinberg (guest): only do that in X code.

[00:24:15] Leo Dion (host): Oh, really? You can't do it in command line.

[00:24:18] Daniel Steinberg (guest): You can't do it in the command line, but the team has said, oh, we see a way forward, and it's something they're

[00:24:23] Daniel Steinberg (guest): considering for a future release and that'll be

[00:24:26] Daniel Steinberg (guest): nice. The other thing from the command line, and this isn't a Swift

[00:24:30] Daniel Steinberg (guest): testing limitation, so much as the way things are built. If I want to test a project, not a package,

[00:24:37] Daniel Steinberg (guest): I have to specify a

[00:24:38] Daniel Steinberg (guest): lot more things.

[00:24:39] Daniel Steinberg (guest): I have to tell you what the scheme is and I

[00:24:41] Daniel Steinberg (guest): gotta tell you what the

[00:24:42] Daniel Steinberg (guest): target is. And so that's not as simple as just typing

[00:24:45] Daniel Steinberg (guest): Swift tests.

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

[00:24:47] Leo Dion (host): Yeah. Right. Overall, what's been your impression of what's come out from WW this summer? You know. obviously we've talked about Swift testing, but has there been a lot of like new APIs or new oss that you've been interested in over the

[00:25:03] Leo Dion (host): past few months?

[00:25:05] Daniel Steinberg (guest): Well, clearly Apple's push is the move to Swift six and

[00:25:09] Daniel Steinberg (guest): getting complete with the, Async APIs, and so that's clearly their push. I think if you read between the leaves,

[00:25:17] Daniel Steinberg (guest): App intents are gonna be very big. It's not something I'm playing with much yet, but it's clear that what they're offering now is telling us you need to start using these are gonna be become more

[00:25:29] Daniel Steinberg (guest): important.

[00:25:30] Daniel Steinberg (guest): Apple intelligence. I don't know how much is shipping in the

[00:25:33] Daniel Steinberg (guest): betas, but I'll tell you

[00:25:35] Daniel Steinberg (guest): yesterday I went for a walk.

[00:25:37] Daniel Steinberg (guest): I forgot to turn off that I was

[00:25:39] Daniel Steinberg (guest): walking and I drove home

[00:25:41] Daniel Steinberg (guest): and it said that I walked eight miles

[00:25:43] Daniel Steinberg (guest): In an hour and that was awesome.

[00:25:47] Leo Dion (host): Yeah, we've all had those before. Have, you, used any of the betas

[00:25:51] Daniel Steinberg (guest): Intelligence or whatever would

[00:25:53] Daniel Steinberg (guest): say, Hey, you're going 30 miles an hour, maybe you're not walking

[00:25:57] Daniel Steinberg (guest): anymore.

[00:25:58] Leo Dion (host): Maybe you should, you know. Apply to the next Olympics, I guess, with that kinda speed. Did You have you installed, the bait on anything yet?

[00:26:08] Daniel Steinberg (guest): Yes. cause I'm an idiot. I've installed the beta on everything.

[00:26:12] Leo Dion (host): Okay.

[00:26:13] Daniel Steinberg (guest): I made it to Thursday of WW week before I put it on my phone. I put it on

[00:26:16] Daniel Steinberg (guest): my iPad right away.

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

[00:26:20] Daniel Steinberg (guest): And so it's been on my carry device.

[00:26:21] Daniel Steinberg (guest): I have a separate partition where I'm running

[00:26:24] Daniel Steinberg (guest): it on my

[00:26:24] Daniel Steinberg (guest): Mac.

[00:26:25] Leo Dion (host): Oh, see, I'm more stupid than you. 'cause I'm running it right now on this Mac.

[00:26:30] Leo Dion (host): that I'm recording, I'm running 15 one, so, I'm even crazier. But then of course my iPhone is still on, what is it? 16? Yeah. Six. No, 17. Right. So I, do you have, you, have you done 18 one yet? Played around with Apple Intelligence on the phone?

[00:26:49] Daniel Steinberg (guest): I've not played around with it. As I said, if it was there. I mean, it should have told me different things, so I have it on the phone, but if it was there, it should, I'm not convinced.

[00:27:01] Leo Dion (host): Yeah, Right, right.

[00:27:02] Daniel Steinberg (guest): But, you know, I feel very strongly that for me, AI is not LLMs is a separate discussion and I'm not really interested in LLMs.

[00:27:11] Daniel Steinberg (guest): I'm very interested in what Apple can do with AI and ml 'cause. I look at what photos does with ml, and I think that's a compelling use case.

[00:27:21] Leo Dion (host): Yeah, and I think that's a big problem is that AI has become LLMs essentially in marketing speak, and Apple has been ahead with like other forms of ai. Like you said, photography's the big one, right? Where like they've been doing photography stuff for years. And other things that they've done with the watch and

[00:27:42] Leo Dion (host): various things where they've detected things.

[00:27:44] Leo Dion (host): The vision. Pro is a great example of that.

[00:27:48] Leo Dion (host): But now it's like the

[00:27:49] Leo Dion (host): total focus is on generative and LLM and it's

[00:27:51] Leo Dion (host): I don't know. We'll see how far that goes.

[00:27:54] Leo Dion (host): I wouldn't say I'm a skeptic, but

[00:27:55] Leo Dion (host): there's only so much LLMs,

[00:27:57] Leo Dion (host): and generative can do.

[00:27:59] Daniel Steinberg (guest): Well, I'm gonna say you're a skeptic.

[00:28:01] Leo Dion (host): you're gonna say, I'm a skeptic.

[00:28:03] Leo Dion (host): I'm just, I'm not a skeptic. I think there are

[00:28:04] Leo Dion (host): big, there's big benefits, but it's not gonna. We're have

[00:28:09] Leo Dion (host): next year. So, a little bit like I don't think it's the, revolution people think it is, let's put it that way. I dunno where you stand on it.

[00:28:18] Daniel Steinberg (guest): I think there are things there.

[00:28:19] Daniel Steinberg (guest): I recently gave a keynote at

[00:28:21] Daniel Steinberg (guest): Swift, which talked about. How do you look at all these things that come out at WW and decide

[00:28:27] Daniel Steinberg (guest): what's for you? And for me, it's a combination of things that are interesting.

[00:28:33] Daniel Steinberg (guest): So Swift testing was interesting, but I also have to find my

[00:28:36] Daniel Steinberg (guest): place in it.

[00:28:37] Daniel Steinberg (guest): And so Swift testing,

[00:28:40] Daniel Steinberg (guest): I find my place in it is, it's something I want to teach. It's something

[00:28:44] Daniel Steinberg (guest): I want to explain and it's something I want to use in my own code. Before I wrote the book on

[00:28:48] Daniel Steinberg (guest): Swift

[00:28:49] Daniel Steinberg (guest): testing. I used it in my shipping apps, and

[00:28:51] Daniel Steinberg (guest): so, you know, the ones that I sent to TestFlight using Swift six have Swift

[00:28:56] Daniel Steinberg (guest): testing in 'em.

[00:28:59] Daniel Steinberg (guest): But for A IML, it's interesting,

[00:29:03] Daniel Steinberg (guest): I don't see where I fit

[00:29:04] Daniel Steinberg (guest): in there because in order for me to do it, I need

[00:29:07] Daniel Steinberg (guest): access to big clean data sets. And

[00:29:10] Daniel Steinberg (guest): that's not something that I, as an indie usually have access to.

[00:29:13] Leo Dion (host): Let's I really like that topic. The, 'cause you talked about that too in Chicago on. Deep dish where you were, like, you talked a little bit about it, where you're like, oh, I wrote a whole book on combine. And well, your talk was specifically about Swift Data, right?

[00:29:29] Leo Dion (host): But you talked about combine, you loved combine, you jumped into combine And then you know, it's been crickets for ever since combine came out.

[00:29:37] Leo Dion (host): And then now you, they came out with this new thing, Swift Data, and it's like, how do you, how like without giving away

[00:29:44] Daniel Steinberg (guest): one of the things I said was because Swift Data had come out last year and deep Dish was about a month before Dubb Dub, and what I said

[00:29:52] Daniel Steinberg (guest): was, I like Swift Data, but before I tell you to dig into it, I would see what Apple does with it. At this year's WW, if there are no sessions. If there's no

[00:30:04] Daniel Steinberg (guest): changes to the APIs, then I would be wary and combine was my warning.

[00:30:09] Daniel Steinberg (guest): That Combine was a beautiful framework. It was great to use. I got a lot out of it, but it clearly was a step, maybe not intentional, but it was a step along the way to Async. And once they made the step towards Async

[00:30:25] Daniel Steinberg (guest): and even async sequences. Start something that are pushed as much as I

[00:30:29] Daniel Steinberg (guest): would've expected.

[00:30:30] Daniel Steinberg (guest): Async sequences initially looked like a replacement for app

[00:30:34] Daniel Steinberg (guest): published. And then we move quickly

[00:30:37] Daniel Steinberg (guest): to

[00:30:37] Daniel Steinberg (guest): async. And so my, my, my only caution there was make sure you're seeing a commitment from

[00:30:45] Daniel Steinberg (guest): Apple into these things before you go in. You know, there was a year, if you're old enough, you remember there was a year

[00:30:51] Daniel Steinberg (guest): where we were gonna have garbage

[00:30:53] Daniel Steinberg (guest): collection on the Mac.

[00:30:56] Daniel Steinberg (guest): And then we weren't. So

[00:30:58] Daniel Steinberg (guest): just sometimes sometimes the

[00:31:01] Daniel Steinberg (guest): people who aren't able to implement what's new because they have support

[00:31:05] Daniel Steinberg (guest): to back, sometimes they're in a great position because they get a couple years to see if something

[00:31:11] Daniel Steinberg (guest): is gonna

[00:31:11] Daniel Steinberg (guest): stick or not. If something's gonna become as important as it

[00:31:14] Daniel Steinberg (guest): looks when you're seeing that first presentation,

[00:31:17] Daniel Steinberg (guest): that is so attractive and enticing.

[00:31:20] Swift Data
---

[00:31:20] Leo Dion (host): Yeah. What did you think about Swift Data this year? Because all, I mean, we just got history stuff, right? Is that sufficient for you to feel like, oh yeah, Swift Data is the future, or are you a bit like, eh

[00:31:32] Daniel Steinberg (guest): get some of the things I

[00:31:33] Daniel Steinberg (guest): wanted. I wanted to see a more

[00:31:35] Daniel Steinberg (guest): powerful predicate. For example, I wanted to

[00:31:38] Daniel Steinberg (guest): see that it could be used outside of Swift UI better because, for example.

[00:31:45] Daniel Steinberg (guest): I don't like this move to us getting rid

[00:31:48] Daniel Steinberg (guest): of the controller layer. I prefer to have the controller dealing with a

[00:31:51] Daniel Steinberg (guest): lot of this and then lightly updating.

[00:31:54] Daniel Steinberg (guest): I'm writing a lot of

[00:31:55] Daniel Steinberg (guest): controller code and model

[00:31:56] Daniel Steinberg (guest): code in my view now, and I don't like that trend, so I was

[00:32:00] Daniel Steinberg (guest): hoping we get more support for outside of

[00:32:03] Daniel Steinberg (guest): Swift

[00:32:03] Daniel Steinberg (guest): ui. One of the things we did get is a very nice support for

[00:32:08] Daniel Steinberg (guest): previews, and so the new,

[00:32:10] Leo Dion (host): Yes.

[00:32:11] Daniel Steinberg (guest): that helps us not sorry, I implemented as a macro. The new support we

[00:32:16] Daniel Steinberg (guest): got for previews is

[00:32:17] Daniel Steinberg (guest): very nice.

[00:32:18] Leo Dion (host): Yeah. Yeah. 100%. Yeah. I mean, so in my, app I pretty much have gotten rid of query in Swift UI just 'cause it doesn't do what I want it to do. And I've moved all my Swift Data stuff to observable objects like the controller essentially. Right? And yeah, I

[00:32:36] Daniel Steinberg (guest): how are you getting updates from that? You then reflect to the.

[00:32:42] Leo Dion (host): I don't like this answer. I use notification center. So there's a way to because underneath, right, it's just core data. And so I use the core data notifications to basically know when something is updated, and then I have basically a bunch of like listeners set up, and then that's how I know when the data has been updated.

[00:33:02] Leo Dion (host): I think I did

[00:33:03] Daniel Steinberg (guest): By the way,

[00:33:04] Daniel Steinberg (guest): did you see the

[00:33:06] Daniel Steinberg (guest): announcements of what may be coming to Notification Center? This is I

[00:33:10] Daniel Steinberg (guest): think, big news.

[00:33:12] Leo Dion (host): Okay. Go ahead.

[00:33:13] Daniel Steinberg (guest): a notification cannot be sendable because a notification is a reference type and it create, contains a user info dictionary, which can contain anything.

[00:33:24] Leo Dion (host): oh God.

[00:33:24] Daniel Steinberg (guest): And so there's

[00:33:25] Leo Dion (host): my existence is these dictionaries with s Yes. Anyway, sorry.

[00:33:30] Daniel Steinberg (guest): so so there's this new proposal to have

[00:33:33] Daniel Steinberg (guest): this notification. I don't remember if it's notification

[00:33:36] Daniel Steinberg (guest): center, do message or notification

[00:33:38] Daniel Steinberg (guest): message, which is sendable.

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

[00:33:41] Daniel Steinberg (guest): It's a great solution to use with Async, and now I

[00:33:45] Daniel Steinberg (guest): can use Notification Center in a very powerful way and not be sending things across actor boundaries and getting all those warnings.

[00:33:54] Leo Dion (host): To me, like the ba like that, like I don't want to get into a Sendible rant, but like the fact that there's so much old code that's like an object based or any base that's there's no way to tell if something is sendible or not. It's just been a real pain in the butt. So yeah, that's gonna be awesome.

[00:34:11] Leo Dion (host): But.

[00:34:12] Daniel Steinberg (guest): one of the nice things if you have architected your app, which I tend to using lots of packages. You can address those one package at a time and update one package at a time, and I find that very powerful.

[00:34:25] Leo Dion (host): Yeah, so speaking of Swift Data, that's kind of where I'm in the middle of right now with my app, my VM app bushel is the fact that I I ended up having a session and they're like, yeah, you can't do persistent model cannot be sendable. I think we've even talked about this offline. But so now I have to change a lot of my code.

[00:34:45] Leo Dion (host): To basically take into the fact that it cannot be sendable and do everything in closures or grab the persistent identifier. And that to me has been a big pain in the neck is like to me. So I

[00:34:58] Leo Dion (host): would think Swift Data would be even more friendly to async

[00:35:00] Leo Dion (host): away considering how new it is, but it's like kind of not.

[00:35:04] Leo Dion (host): And I think, we specifically talked about the fact that like why is model, why are models, classes

[00:35:09] Leo Dion (host): and things like that.

[00:35:10] Swift Data 🙃 Sendable
---

[00:35:10] Daniel Steinberg (guest): Well, and that's what I was gonna say is that's the difference between the Swift team and the Swift UI team is Swift Data, I thought would've been the opportunity to make these things value types. And then they would've been easier to send. Although we might have gotten into issues with non copyable but it would be nice to be able to send these things across And so you end up sending sort of a representation of them so that you can get updates.

[00:35:37] Leo Dion (host): Right, right. Yeah, that's kind of what I'm doing is just grabbing the persistent

[00:35:40] Leo Dion (host): identifier and using that and then kind of co copying the fields. but that's so it feels like so awkward and it could be so easily done in another way Like I get that it's a class because underneath It's a reference to some.

[00:35:56] Leo Dion (host): SQL light file somewhere. Right. But at the same

[00:35:59] Daniel Steinberg (guest): we know that

[00:36:00] Leo Dion (host): Right, right. I know. I'm agreeing.

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

[00:36:03] Daniel Steinberg (guest): So, so all of what? All of what you just said, I lost my thought. I'm sorry.

[00:36:11] Leo Dion (host): that's okay. I mean, I kind of think that's

[00:36:13] Leo Dion (host): what I feel like they're

[00:36:15] Leo Dion (host): trying to push away

[00:36:17] Leo Dion (host): from classes as much as possible and get everything to be a non copyable,

[00:36:22] Leo Dion (host): structor or an actor. it almost feels like That's

[00:36:24] Leo Dion (host): kind of the trend in a lot of ways.

[00:36:28] Daniel Steinberg (guest): I'm, so a lot of what we have to do is put things on the main actor.

[00:36:34] Daniel Steinberg (guest): It looks like we're putting a lawn on the main actor

[00:36:36] Daniel Steinberg (guest): until you actually go through debugging or look at instruments, and you find out that things are pushed off the main actor when they can be every time you hit in awai.

[00:36:47] Daniel Steinberg (guest): And so

[00:36:48] Daniel Steinberg (guest): at first it feels like we're putting everything on the main actor and why

[00:36:51] Daniel Steinberg (guest): isn't

[00:36:51] Daniel Steinberg (guest): this slowing things down? But when you dig into the async, sometimes you find

[00:36:56] Daniel Steinberg (guest): out, yeah, but when the system can push things off to

[00:37:00] Daniel Steinberg (guest): a background thread, it's happening

[00:37:02] Daniel Steinberg (guest): for you,

[00:37:02] Swift Macros
---

[00:37:02] Leo Dion (host): Oh, okay. That's really interesting. Makes sense. Yeah, so I wanna talk a little bit about your Swift craft talk that you did in England a few months ago. Macros. Macros are one of those things where I'm afraid they put, they invest. Apple invested a lot into it. And then we haven't heard a lot as far as making app, making, building at macros better.

[00:37:29] Leo Dion (host): But then at the same time, we do see a lot of macros everywhere whenever they can. Where do you, like, where do you see the future of macros and where they're headed?

[00:37:40] Daniel Steinberg (guest): So one of the problems with Swift evolution is we see everything that's being added to Swift, and we think everything is for us. Some of the things aren't for us, like you can go through the rest of your life and never write a macro and still benefit from macros. Pound preview in Swift UI is a macro that got rid of so much dumb boilerplate code.

[00:38:07] Daniel Steinberg (guest): It's, in my opinion, the perfect macro and so Swift testing at Sweet

[00:38:15] Daniel Steinberg (guest): at test. The tags are at

[00:38:18] Daniel Steinberg (guest): tag pound, expect pound

[00:38:20] Daniel Steinberg (guest): require. These are all macros. And so I'm using it all the time. Do I have to be writing my own? And also the ones that we write, as opposed to the ones that Apple writes, we have to bring in Swift syntax, which slows down a clean build.

[00:38:37] Daniel Steinberg (guest): And so, although I liked writing macros and I still write macros,

[00:38:43] Daniel Steinberg (guest): I don't think they're for us primarily.

[00:38:46] Daniel Steinberg (guest): I think they help. I think they help make the environment we live in better. But before you write your own, you really should question, can you do it any other way? Could you do it with a function, for

[00:38:58] Daniel Steinberg (guest): example?

[00:38:59] Daniel Steinberg (guest): Could you do it with a protocol? And so if there's another way to accomplish what you wanna accomplish, then don't reach for a

[00:39:06] Daniel Steinberg (guest): macro that macros are great when they're used for What they should be used for.

[00:39:13] Leo Dion (host): What do you think is a great example of when you should create a macro? Do you have a checklist of

[00:39:17] Daniel Steinberg (guest): so my example was pound

[00:39:19] Daniel Steinberg (guest): preview. 'cause if you think of pound preview before pound preview, we had to come up with Some name and we tended to name it whatever the view was. Under

[00:39:31] Daniel Steinberg (guest): previews, we had to conform to

[00:39:33] Daniel Steinberg (guest): something. Conforming to that thing meant we had to

[00:39:36] Daniel Steinberg (guest): implement something, and so we implemented this computed

[00:39:39] Daniel Steinberg (guest): property inside of the struct, and all we cared about was what are we presenting in the preview pound preview says type

[00:39:47] Daniel Steinberg (guest): pound preview, and give me the thing you're presenting.

[00:39:50] Daniel Steinberg (guest): End of the day, that's a beautiful macro. That's a great use of

[00:39:54] Daniel Steinberg (guest): macro. So, in Swift Data for example, they gave us a way of creating something that would present data

[00:40:01] Daniel Steinberg (guest): in a macro. And most of what we have to type in is

[00:40:06] Daniel Steinberg (guest): nonsense. And I would've done this in a

[00:40:08] Daniel Steinberg (guest): function

[00:40:09] Daniel Steinberg (guest): except if you

[00:40:11] Daniel Steinberg (guest): give me a

[00:40:11] Daniel Steinberg (guest): function that accepts a vari

[00:40:14] Daniel Steinberg (guest): inside the function that's

[00:40:15] Daniel Steinberg (guest): transformed into an array.

[00:40:17] Daniel Steinberg (guest): I can't then turn around and call apple's function that requires a very at,

[00:40:22] Daniel Steinberg (guest): so I had to create a macro, and so I created a macro,

[00:40:25] Daniel Steinberg (guest): that

[00:40:25] Daniel Steinberg (guest): makes adding preview

[00:40:27] Daniel Steinberg (guest): data really trivial and

[00:40:29] Daniel Steinberg (guest): gets rid of a page of this boilerplate,

[00:40:32] Daniel Steinberg (guest): which is just it's, not that

[00:40:34] Daniel Steinberg (guest): it's not important, but it's non-interesting and it never changes.

[00:40:38] Leo Dion (host): Do you think at its core macros are a way to bring the dyna dynamic abilities of Objective-C into Swift, essentially.

[00:40:48] Daniel Steinberg (guest): I,

[00:40:48] Daniel Steinberg (guest): don't

[00:40:49] Daniel Steinberg (guest): think that the dyna, I think that the dynamism of Objective-C is very

[00:40:54] Daniel Steinberg (guest): powerful and a

[00:40:56] Daniel Steinberg (guest): runtime thing. So macro is a compile

[00:41:01] Daniel Steinberg (guest): time thing.

[00:41:02] Leo Dion (host): The reason I'm saying that is like with Objective-C, you could change stuff on the fly all the time. And there's certain things You could do with Objective-C reflection wise, for instance. And it seems like with macros, it's a way of like basically changing a certain type on the, kind of, on the fly, but not really like by, by basically modifying the code.

[00:41:27] Leo Dion (host): Because it's

[00:41:27] Daniel Steinberg (guest): I wanna stress it. It's a compile time issue. It's not this change isn't happening at runtime.

[00:41:33] Leo Dion (host): right, right.

[00:41:34] Leo Dion (host): Obviously. Yeah. Yeah,

[00:41:35] Daniel Steinberg (guest): well, it not obviously

[00:41:36] Daniel Steinberg (guest): be it needs to be,

[00:41:37] Daniel Steinberg (guest): say, stated,

[00:41:38] Daniel Steinberg (guest): right? Because that's Objective-C. We could do stuff at runtime.

[00:41:42] Leo Dion (host): Yeah. Yep. Yeah, that's a good point.

[00:41:44] Books and Conferences
---

[00:41:44] Leo Dion (host): Before we close out you got. Books. You got a books

[00:41:49] Leo Dion (host): a book coming out specifically on Swift testing. Do you we'll put a link, you'll have a pre-order link that we can share with our audience. Okay. Awesome. Do you have any other books coming out? Probably updates right.

[00:42:01] Daniel Steinberg (guest): I have both books and I have updates. What I'd like to do is make sure that my, my books are still relevant. So I updated my Swift intro book for the last time I've End of Life Did, but it now works in Swift six. I don't think the intro material will change. I'm going to write a Swift six book, which is for sort of that next level stuff.

[00:42:22] Daniel Steinberg (guest): What have we gotten, not just in Swift six? 'cause a lot of

[00:42:25] Daniel Steinberg (guest): what we call Swift six, we got in Swift five, nine five, ten five. You know, it's been evolving

[00:42:31] Daniel Steinberg (guest): towards this. And so I want to talk

[00:42:33] Daniel Steinberg (guest): about that

[00:42:34] Daniel Steinberg (guest): just because I'm an idiot. I don't know if you've noticed, my last books have all used sort of a detective

[00:42:39] Daniel Steinberg (guest): theme and so I've had this running detective story.

[00:42:43] Daniel Steinberg (guest): The Swift six book will have a Winnie the Pooh theme because of the Winnie the Pooh

[00:42:48] Daniel Steinberg (guest): book. Now we are six, of course, now we

[00:42:50] Daniel Steinberg (guest): are Swiss

[00:42:51] Daniel Steinberg (guest): six. And

[00:42:51] Daniel Steinberg (guest): so

[00:42:52] Leo Dion (host): Right, right, right.

[00:42:53] Daniel Steinberg (guest): looking forward to playing with that.

[00:42:55] Daniel Steinberg (guest): I have to update my

[00:42:56] Daniel Steinberg (guest): async book to Swift six, my macros book to Swift six, my data

[00:43:00] Daniel Steinberg (guest): flow in Swift UI, book to Swift six. and I may also update,

[00:43:05] Daniel Steinberg (guest): it should be a light update, the functional

[00:43:06] Daniel Steinberg (guest): book and the Swift UI kickstart, and those will be end of

[00:43:10] Daniel Steinberg (guest): life with those updates. But the Async

[00:43:13] Daniel Steinberg (guest): book, the data flow and

[00:43:14] Daniel Steinberg (guest): Swift UI and the Macros book, those

[00:43:17] Daniel Steinberg (guest): will continue to live. I'll continue to update those.

[00:43:20] Leo Dion (host): Awesome, and we'll put links to those in the show notes as well. And then you have a bunch of conference appearances you'll be making. Mostly Europe, I think, right?

[00:43:29] Daniel Steinberg (guest): Mostly Europe.

[00:43:30] Daniel Steinberg (guest): I'm just a stranger in my own land.

[00:43:32] Daniel Steinberg (guest): But so, so

[00:43:34] Daniel Steinberg (guest): the easy answer is if I'm at a conference, it's because I was invited. If you ask me, I generally say yes. And so if I'm not at a conference,

[00:43:43] Daniel Steinberg (guest): 'cause I wasn't invited, and so, I'll be going to Swift Island and

[00:43:48] Daniel Steinberg (guest): ISW

[00:43:48] Daniel Steinberg (guest): uk. Those will probably be before this

[00:43:51] Daniel Steinberg (guest): post, I'm doing

[00:43:53] Daniel Steinberg (guest): a Swift

[00:43:53] Daniel Steinberg (guest): testing workshop at iOSDevUK and then at NS Spain.

[00:43:58] Daniel Steinberg (guest): I'll also be doing a talk at NSSpain on macros and another talk on

[00:44:02] Daniel Steinberg (guest): macros at server side swift at the end of

[00:44:05] Daniel Steinberg (guest): September. And so,

[00:44:07] Daniel Steinberg (guest): Busy time coming ahead. And then

[00:44:08] Daniel Steinberg (guest): finally in October, I hope to see you in Bologna

[00:44:12] Daniel Steinberg (guest): for Pragma call,

[00:44:13] Daniel Steinberg (guest): which is just also, these are all just such

[00:44:16] Daniel Steinberg (guest): great conferences, great community and amazing organizers.

[00:44:20] Leo Dion (host): And I will see you in London for Server side Swift. I'll be doing my talk on how does Server Side Swift work out in the real world. And I literally mean out because it's a fitness app. So yeah, I'm really looking forward to that. We'll have links to all that stuff in the show

[00:44:37] Daniel Steinberg (guest): It'll be great to see you there and maybe we'll do a meal together.

[00:44:40] Leo Dion (host): I know. Yes, I know.

[00:44:42] Leo Dion (host): Locks, locks and bagels like, you know, I'm like addicted to it. Thanks to you So. Daniel, thank you so much for coming on. This was fantastic.

[00:44:49] Daniel Steinberg (guest): My pleasure.

[00:44:51] Leo Dion (host): W can people find you online?

[00:44:53] Daniel Steinberg (guest): Dim sum thinking pretty much everywhere. Dim sum thinking.com includes links to everything I do. And then on socials, I'm blah, blah, blah. Dim sum thinking.

[00:45:02] Leo Dion (host): Yep. Awesome. People can find me on. Social media at Leo Dion. At Leo Dion at C Im on Mastodon. If you're watching this on YouTube, please and subscribe. I'd really appreciate it. As you can see, I'm in, can you see? Let's see. No, maybe not. I'm moving. So, I don't know when this episode will come up, but hopefully soon.

[00:45:26] Leo Dion (host): You know, where it's still relevant, so, yeah. Yeah, that'll be my busy project

[00:45:30] Leo Dion (host): for the next few weeks. Thank you everybody for joining me, and it was good to see you. Bye.