EAS-197
===
Natalia's Background and SwiftUI Book
---
[00:00:00]
Leo Dion (host): Welcome to another episode of Empower Apps. I'm your host, Leo dn. Today I'm joined by Natalia Panferova.
Natalia Panferova (guest): Hi. Really excited to be here.
Leo Dion (host): Yeah. so I'll let you go ahead and do the introduction.
Natalia Panferova (guest): Hi, I'm Natalia. I am based in New Zealand and I'm an iOS developer and macOS developer now as well. I work at Nil Coalescing, which is a small company I founded together with my partner a few years ago. we do some consulting and freelancing, and we have a blog, nilcoalescing.com/blog .
Leo Dion (host): Yeah, we've been chatting about your, just a couple of your blog posts you've done with macOS, but you have a new book out, right? SwiftUI Essentials. You wanna talk about that a little bit?
Natalia Panferova (guest): Sure. Yeah. It just went out last week. it's called SwiftUI Fundamentals and it's a guide. On the course framework, principles and APRs. It's something I wanted to write for a while. Just never Got a chance [00:01:00] to sit down and write that for a bit. Yeah, and it's sort of combines my experience and my knowledge from working, with SwiftUI since it was released, but also working on the course with I team at Apple, from 2020 to 2022.
So, after I left Apple, I worked a bit in the industry and I noticed that . The framework obviously became very popular, but there are still a few misunderstandings and some people find it quite difficult to understand how it actually works and why it works the way it does. So I was hoping that guide could help to clarify some things and help people to use the framework more effectively in their project.
SwiftUI Insights and Tips
---
Leo Dion (host): Yeah, we've done a lot of episodes on SwiftUI. people are still trying to figure everything out. we had some really great episodes with Ariel and, Craig and a few other folks, It's really odd to have you on, you actually worked on SwiftUI when you were at Apple.
Natalia Panferova (guest): Yes, I did. I worked on the core SwiftUI team. Back then, we were just 10 people and we were focusing on iOS APIs, like the core APIs, like [00:02:00] navigation, search, text,
Leo Dion (host): and They didn't severance you or anything, right?
Natalia Panferova (guest): Yeah, I remember some. I don't remember everything, but I remember hopefully the most important things.
Leo Dion (host): So like, what are the things that most people don't get about Swifty y.
Natalia Panferova (guest): I think, it's a bit too magical for most people. Like it does some things and you dunno why it does them. it's trying to be really clever. So like a lot of work behind the scenes goes into figuring out how to do the best thing. Outta the box. So you just define a view and it just works and it works differently, different contexts.
So like under the hood, CI has this environment which we can also use for our own values or reading the values from the environment. But CI also uses that to understand what context the current view is on and how To display it, it can be completely different based on the platform or it can be different based on where in their hierarchy it's presented.
Like buttons can look completely different in navigation bar in [00:03:00] sidebar, in, slide their actions and they just look a bit different depending on where they are.
Leo Dion (host): Yeah. 'cause that really reminds me of what Paul was saying, Paul Hudson, talking about how, like, yeah, it depends on the platform, where it's situated, it's a markup, and then kind of you're handing off Apple to deliver the way they feel fit. what might be some tips you have for someone who, who's just getting started with SwiftUI? And does it have any knowledge of UI kit, which is becoming more often the case than not? for getting started with SwiftUI.
Natalia Panferova (guest): I think as you just get started, You can just get started with UI and build. quite complex apps without UIC knowledge. I would recommend to not fight the framework, but sort of work with it and customize things you can customize maybe if something is not quite working out adjust your app design a little bit. It's gonna be easier and more robust in the future because if you start [00:04:00] to hack it, it's just going to break with the next release So that's what I try to do in my own projects.
And when I work in companies as well. I would talk to the designers saying, this is a great design, but it's gonna be really difficult to implement. Can be adjusted slightly like this 'cause it's gonna be. Easier, faster, and it'll be working better in the future as well. So that's, I think, one way to look at it.
but I think like as you progress, it's still useful to learn your kid, firstly because a lot of C two APIs still rely on your APIs under the hood, like the push navigations, the model presentations. And then a few things you might need to integrate with UI Kit to support. So I think as like, you don't need to tell them both frameworks straight away, but it's useful to know them both in the end, I think.
SwiftUI "Pet Peeves"
---
Leo Dion (host): what are some pet peeves you've heard people tell you about SwiftUI and what do you think are some misunderstandings that people would have to have those pet peeves,
Natalia Panferova (guest): Yeah, I think definitely state [00:05:00] management and like the data flow and how to structure it is a hard one, for many people to get, I think straight away, especially because it changed over the years as well. Like at first we had all of these like property wraps and you had to understand them all and choose the correct ones, and now it's a bit less.
But yeah, it just changed recently, so people just started to get the, the previous way and now it's a new way and it's all bit
Leo Dion (host): do you prefer?
Natalia Panferova (guest): I use the new way now in my projects, like with observable and state, just because it's supposed to be more performant because observable object had some issues.
That's why I guess observable was done.
Leo Dion (host): Right,
Natalia Panferova (guest): but it took me like probably a few months to switch to the new way as well.
Leo Dion (host): Right, right. Yeah. I mean I've pretty much gone all in on observation with anything that can support that os 'cause that's the other issue, right? Is like if you have to support it old enough os then you can't use the new shiny stuff. one of the things you've been talking about in your blog is scenes.
I think that [00:06:00] is a concept people don't understand, and how they work. We kind of just have usually one scene, right? and then everything goes into that. what do you think people are missing when it comes to scenes In SwiftUI?
Natalia Panferova (guest): I think people maybe don't think about scenes so much because you create a new project and it's already there. The window group, which probably most apps use. the trick to understand is that it's not one scene. It's like actually multiple scenes. CUI will create as people open new windows, it doesn't work this way on iPhone because you can only open one window of
Leo Dion (host): Right,
Natalia Panferova (guest): Most apps will probably still run on the iPad and that people can open multiple windows. If you use the window group well, which you probably will, and each scene will have a new state. So like if you have a state you want to preserve for the entire app, so that it's the same consistent state in every scene.
For example, you have some counter or something and you want to have it. be the same in every scene, then you have to put it on the top level in the app because if you initialize [00:07:00] that state object inside the content view or any other view, it's going to be reset. Like it's because since will create a new hierarchy from scratch with new state, and everything for every scene.
So that's something to keep in mind, I think.
Leo Dion (host): I think for me, like SI didn't get scenes until I started doing Mac OS development. 'cause then like you said, you could have multiple windows and things like that. I guess iPad, you could have multiple scenes, right? Because technically you could have multiple windows. So, and I would assume Vision OS and I don't know about TV or definitely not watch, Yeah, that's I think where you, you really see where scenes are, are useful. So there's like scene storage and then there's app storage, what, what are all those and what are they useful for?
Natalia Panferova (guest): Yeah, so these are some helpers of property robots that we can use to store some small amount of data app storage is just wrap around user defaults, so that's something you want to persist, [00:08:00] between, app launches reliably, but it has to be quite small. Same as user defaults.
So it could be some username or some other user setting. Some configurations that you want to persist, you can store them there. And since storage, it's for state management. This is something if you want to persist the app state between, launches. It also has to be quite small amount of data,
I does not guarantee it's gonna be saved because. If the app is quit, it's going to be cleared or if the app terminates. and so if I didn't have time to save it, it's also going to be cleared. But it's not like, it's just the app state, so it's not a disaster if it's not persisted, but it's nice if it is.
Leo Dion (host): It's like, does it use, so like with, with, okay. Sorry, with Mac Os you have like Windows State and that's stored somewhere in like app group or, you know what I mean? But that's different from seeing storage or app storage. App storage is basically user [00:09:00] defaults. Right.
Natalia Panferova (guest): App search is user default under the hood.
Leo Dion (host): SwiftUI previews, What are some tips you have for using them? do you always try to have a SwiftUI preview in all your views, or are you just kinda like, I give up, this isn't worth my time?
Natalia Panferova (guest): Yeah, I try to have previews for smaller views where it's faster to build the UI With Swift, I don't have mockups or something I used to in Sketch, but now I just usually build something and see how it looks straight away. So for that I use the previous just sort of design with SwiftUI
Leo Dion (host): right.
Natalia Panferova (guest): I would do that for smaller views.
usually and something like content view or some like wrap reviews, I usually just delete them.
Leo Dion (host): I basically do the design in a separate clean Xcode project. I can make the design as complicated as I want and just hard code a bunch of values and then copy it over and then put everything to a state instead One thing I wanted to ask about was, so we talked about Swift eye previews, let's talk about layout and I mentioned [00:10:00] geometry reader and things like that. What are some ways of getting around some of the pet peeves, sorry to use that term again. with or some of the things that bug people when it comes to layout.
'cause I know we got some custom layout stuff that we can do now, but, People still struggle and sometimes they still end up using Geometry Reader and things like that. What are people doing wrong when they maybe are overusing those or don't need to use them
Natalia Panferova (guest): I use geometry sometimes as well. I think the important part is not to create like a cycle. If you use the geometry, they have to be careful not to, to like read the geometry, write it somewhere else, so it's horrendous.
Leo Dion (host): Okay.
Natalia Panferova (guest): I think I know there are few more tools now, like few new APIs that can help us to avoid using the geometry rhythm. Like I saw there's container relative frames, I think something we can use. And the other few like things for scrolling as well that are helpful now I think as well.
I could layout and. Can be different from a few other frameworks. So you have to sort of get it how it works, like [00:11:00] how, the size is allocated. The fact that you can't force a size on a view, it just will be the size it wants to be. How F works. It's actually not like, it's just another view wrapped in your view.
It's not like it doesn't assign the frame to your view, it's just another view with that frame that drops
Leo Dion (host): Mm. Yeah, that makes sense. and I remember having Chris ID off on and talking about how Sizes the way they're suggested in the hierarchy, like how a size might be suggested by a parent or a child, and I don't, do you know what I'm talking about?
Natalia Panferova (guest): So like the parent suggest the
Leo Dion (host): that work?
Natalia Panferova (guest): so it starts with the fresh app. the parent use, I create, and then it suggests the space to the root view, the content view, and then the content view, suggests this space, this child, and then the child says, okay, I want to be that big, based on that suggestion.
And then the parent says, okay, this is the space I have. the child wants to be that big, so I will position it here. most often it's in the [00:12:00] middle. if you do geometry for example, it'll go to the top. So like the parent decides how, where to position the child, well, the child decides how to size itself based on that.
Leo Dion (host): It makes complete sense. Do you still use combine,
so, how do you use it?
Natalia Panferova (guest): I didn't use it that much like over the whole time because it was a research UI and like search UI obviously relied heavily on it, so I did use it. When I used observable objects but didn't use like that much. All the other features of combined, because I worked with Swiss for one year and then I started working at Apple.
Leo Dion (host): do you have any use cases where you use it now? in any of your client apps?
Natalia Panferova (guest): I use sync sometimes, like to, to like sync on a value. I used that when I was integrating with UI Kit and I had to observe the changes to like an observable class in UI kit. So you have to like call sync to update manually your UI kit
Leo Dion (host): Are you using like key value observation and then creating a publisher from that?
Natalia Panferova (guest): For example, you have observable object, which is the older way and you have a published [00:13:00] property and then you create the cancelable, you save it and then you sync, on that published property and you get a callback when it changes and then you can make your update.
You like it view. That's how I create it. And like two way connection between UA and UI kids.
Leo Dion (host): I think it makes sense when you have something that's like, starts off already being a publisher. Like a timer or a notification or any of that stuff. But otherwise, like if you're doing a network call, yeah, I am pretty much been doing all async weight now when it comes to that stuff.
Natalia Panferova (guest): I was going to say.
Leo Dion (host): Have you
Natalia Panferova (guest): and it was already, so
Leo Dion (host): Have you had any issues doing async weight in Swifty
Natalia Panferova (guest): I don't think I had any, but I'm not sure, like a hundred percent I'm using every time correctly . So yeah, I'm using it and,
Leo Dion (host): how are you doing it?
Natalia Panferova (guest): Yeah. I use tasks. I know that you shouldn't be using too many tasks because it can like, create way too many, threads for you and then it's gonna be a problem, but I don't usually have that many tasks, so it's still, it's working.
Natalia's Journey
---
Leo Dion (host): how did you get started in [00:14:00] development?
Natalia Panferova (guest): It was, a while ago and I started with Java 'cause I was going to study computational linguistics. So I was learning data structures, algorithms, and then I was learning Java and Python because that's like, especially Python is what was going to be used mostly. Then I got a job, doing web . So I just didn't go to study.
In the end, I was just working, doing some frontend development. then I learned full stack development as well. after that I started learn iOS because I wanted to experiment with one project and seemed like iOS was the right way to do that because it's self-contained and small. But you can still sell your products.
Leo Dion (host): is there anything you miss about not developing for the iPhone?
Natalia Panferova (guest): I still do web
Leo Dion (host): Do you miss Java?
Natalia Panferova (guest): I don't remember it anymore. I think I haven't used it for a while. But I still do web. most of the web development I do now is with Swift because I usually build static websites.
Leo Dion (host): what are you using to build your static website in
Natalia Panferova (guest): Publish. it's by John Sandel. we have our own fork and we're trying to maintain it somewhat
Leo Dion (host): so how did you end [00:15:00] up at Apple, if you mind me asking?
Natalia Panferova (guest): I was, using SwiftUI building with SwiftUI since like the first year it was released. And I started my blog and I was publishing articles about whatever, hacks I came up with because the first version SwiftUI was really limited.
Leo Dion (host): Mm-hmm
Natalia Panferova (guest): so the blocks that's growing and. It was like a different newsletter and I was posting on Twitter back then, and then someone from the team reached out and said, we found your blog.
It looks like you're really passionate about the framework. They wouldn't come and work with us. I started like I interviewed and then it took like a few months to get the job in the end,
SwiftUI and macOS
---
Leo Dion (host): Right, been doing Mac os development lately, or did you just, start doing the macOS stuff?
Natalia Panferova (guest): So I was doing a bit
Leo Dion (host): you get into it?
Natalia Panferova (guest): Yeah. I was doing it a bit, before I joined Apple because I was like, oh, we have SwiftUI now. I don't need to learn AppKit. I can just do something with SwiftUI. But yeah, I started sort of trying it out a bit and then I obviously had to learn a bit more about that because I was building APIs for Marcos.
it was tricky because like, [00:16:00] I don't know the platform as well as I know iOS.
Leo Dion (host): Okay.
Natalia Panferova (guest): but yes, had to learn, had to talk to other people because if you build a text, API, it is going to be used everywhere, across all platforms. So you have to make sure it makes sense everywhere.
Leo Dion (host): Right.
Natalia Panferova (guest): Yeah. and now recently I just, I have more time for my own projects now as well. So I want to try to build more micro assets just because it's a bit more fun because it's more new for me. lots of room for experimentation.
Leo Dion (host): How far back did you do Mac OS development with 50 Y.
Natalia Panferova (guest): I tried the first year, 2019.
Leo Dion (host): Okay. We, and you were like, this is great. Or were you like, oh, because I just remember that I had done a little bit of that kit, not a lot, and I was just like, this is rough.
Did you, what, how did you feel about it?
Natalia Panferova (guest): Yeah, I thought it was quite difficult and like the design was difficult for me as well to understand what to do with micros. But with iOS, I sort of understand what I want with micros, it's more difficult for me.
Leo Dion (host): yeah. So, as I've been talking [00:17:00] about it on the podcast, I've been doing a lot of Mecca West development with Bushel, and there were some articles that really interested me, that you had recently. Well, building like a menu bar utility. You want to talk about that and like how cool that is and why, and why.
Why is it so powerful to do in Mac Os?
Natalia Panferova (guest): Sure, yeah. I wanted to build like a tool for myself, that, I would use, basically I write my blog in lockdown and the lockdown parts that we use, it struggles to par URLs for Apple Doc, like, when they have brackets. so like fails every time. So I have to code them manually.
So I'm like, I just want a tool that's . I can like press the keyboard shortcut or something, and I just like euro code, your codes, euros for me. So I'm like, oh, it could be a cool project to try to build as a micros utility just to learn new things and I can use it myself as well,
So I thought my new bar would be the right thing to do because it's quite limited functionality, maybe too much. I tried using the menu by extra. Worked out mostly. Well, there [00:18:00] were a few things. They were tricky, like sizing the icon to the custom icon to use for the menu bar.
They had to drive your things, had to go with some hack in the end then like presenting settings window, the, the, in the way that it like behaves the same way as other settings windows, like, so it comes to the front straight away, but then doesn't stay at the front. Mine stays because I use floating window for that.
Leo Dion (host): Okay.
Natalia Panferova (guest): Yeah, or just the fact that you can't add right click to the menu bar. like many menu bar apps, you can right click on them and they show additional options. Quit, button. And I couldn't implement that. I couldn't find a way to implement that in my app.
Leo Dion (host): Did you had to do anything with AppKit or Relic was what's, is it NSVU Representable or any of that stuff to like, where have you had, where have you found the need to do that? in your macOS app development?
Natalia Panferova (guest): so I haven't used wrappers, but I did use, AP Delicate, like n as App Delicate,
Leo Dion (host): Okay.
Natalia Panferova (guest): Yes, yes,
Leo Dion (host): Yeah. [00:19:00] Okay.
Natalia Panferova (guest): yeah.
Leo Dion (host): Well, what did you have to use it for?
Natalia Panferova (guest): I think it's something to do with the startup of the app. I think maybe it's to present. I wanted, like when the app is first opened, I wanted to open the, like, because when you start the menu bar app, it just starts with an icon in the menu bar, but it doesn't open the app.
And I think I used something from AppKit to open for
Leo Dion (host): you want it to open the menu bar,
Natalia Panferova (guest): Yeah.
Leo Dion (host): . That's where you have that like application as agent. 'cause then it thinks, oh, you just want like. A menu bar item where it's like, no, you want a window too. what are some things if I, an iOS developer and you want to build your first Mac app and you want to use SwiftUI, what are some other things that maybe somebody should know about? if they're gonna get into macOS development.
Natalia Panferova (guest): I think there's a few more ways to integrate with the system and I think users will probably expect more system integration from Marcos app. Like you can, add an option to start the app or start up like a launch [00:20:00] login it. Then you can add system services. That's what I looked at as well.
Leo Dion (host): Are you looking at App Store and Sandboxed, or are you looking at outside App Store.
Natalia Panferova (guest): So for now App Store, but we are thinking of building our own platform to sell apps from, just from our website. Especially now we have like a book platform so we could adapt it to sell apps just because it is probably gonna be faster and a bit more like we would be more free to what APIs we can use.
Leo Dion (host): One of the things I've had to do, is, getting into the NSWindow API and like assigning a NSWindowDelegate. I've had to do that quite a bit because there's certain things I want to do, like. Get rid of like the minimize button or other things like that.
Or changing the size. so I started building bushel not this year, but the year before. And I know they've added some stuff for Windows SwiftUI and Mac Os. there's a lot of power in that. That, I've found when it comes to stepping [00:21:00] back to the app kit stuff when I need to,
Natalia Panferova (guest): Yeah.
Leo Dion (host): So another book out your last year, right, called Swift Gems. what is that about and how is that different from your new book? SwiftUI Essentials.
Natalia Panferova (guest): Yeah, so Swift Jams is more like a collection of tips that have been collected over the years because I think it's fun to find this like little nuggets of information that you can use, instead of a book that you can open on any page and like, oh, this is a cool Swift feature I can integrate right now into my project.
And some of them are like syntactic sugar that will make coat cleaner or prettier, or some of them are. for optimization purposes as well, like some ways to deal with collections, that could your code as well. So it's like a few different things that I've been collecting and I thought, why not put them into a book and organize them like by topics?
So it was like a fun thing to do, especially like last year I was also employed, so I had a bit less time. that was a perfect book to write because I could do it in the evenings. I didn't have to like sit down and write it all at once. Could like write a tip every [00:22:00] evening.
Leo Dion (host): What kind of feedback have you gotten from people where they're like, oh, I totally didn't know about that.
Natalia Panferova (guest): the mostly quite happens that, oh, there's like so many things I didn't know that's like amazing. And I was like, yeah. And I also like, forget those things. I remember writing about that. I should go back to my book and see what I wrote about that so I can use it as well. So it's good for me as well.
Leo Dion (host): I think this has been great. Natalia, thank you so much for coming on the show. I really appreciate it. or can people find you and your books, online?
Natalia Panferova (guest): So it's neil co.com. So Neil Co is like the operator and Swift. the blog is neil co.com/blog and the books is books dot neil co.com. And I'm also on all sorts of social platforms like X Masteron, blue Sky, LinkedIn, so it's at not Rova, on X.
And Masteron Social as well, not Rova and Blue Sky. It's also the same, not fer.
Leo Dion (host): Yeah, and we'll have links to all that in those show notes. So [00:23:00] definitely take a look at that. thank you so much, Natalia, that was really good and super informative. Thank you.
Natalia Panferova (guest): Thank you for inviting me.
Leo Dion (host): People can find me online. Leo g Dion, I'm on all the stuff. If you're watching this on YouTube, please like and subscribe. And if you're listening to this on your favorite podcast player, please post a review, share this online, and we will talk to you again. Bye [00:24:00] [00:25:00] everybody.