Extension for inverting the Color of your image in SwiftUI based on .dark or .light theme

I am using this little extension to invert the colors of the icons in my app. The icons are in black and white, and designed first to be used in the .light theme mode, that means they have beed design in black lines, so when the user will switch to dark, the icons should change the lines to white.

struct DetectThemeChange: ViewModifier {
    @Environment(\.colorScheme) var colorScheme

    func body(content: Content) -> some View {
        if(colorScheme == .dark){

extension View {
    func invertOnDarkTheme() -> some View {

//usage example

Image("iconName").resizable().scaledToFit().frame(height: 40).invertOnDarkTheme()

That’s it, now let’s get back to WWDC2022 which will start in a couple of hours.

Error – The VNCoreMLTransform request failed

If you are working with the vision framework and you are getting this error, while testing the iOS app in simulator, well, test it on the actual device and see if the error goes away. Very unfortunate error description.

This was very confusing personally, since the code was working fine while I was using it on an macOS app. Also I did not find any warnings anywhere that you are supposed to only test it on an actual device. Not sure how this makes any sense, but glad that I figure it out, It drove me crazy for the last 2 days.

Today I started coding (using Xcode) on the MacBook Pro 16 2021, here are my first thoughts

Let me start with the main reason I switched from MacBook Air to MacBook Pro 16, easy to guess, screen size. After coding for a while on the Air, I realized that I need a bit more real estate for running the simulator or seeing the changes in the Canvas while working on some SwiftUI component. For a while, I used my old iPad Pro as an “external monitor”, but still I found, I moved my head too much and break the concentration from the current task. I have tried using my desktop monitor, but it is a little too big and again I found that I moved my head a bit too much, weirdly enough, I preferred to go back to my 13 inch screen. This is one of the reasons I actually didn’t went for a desktop iMac, while the bigger screen is good if I would edit a photo or do some drawing, for actual coding, I prefer something smaller.

My Air is light, very light, you can pick it up with two fingers and feels safe in your hand. The MacBook Pro 16 is much more heavier, I can’t pick it up with two fingers at all, I have to actually use the whole hand. But it’s not a problem at all, and is something that I can get used to it. The reason, I do need to quickly hold the laptop in one hand, is that sometimes I need to protect it from the incoming tornado that is my 2,8 year old son rushing in my office and jumping straight on my armchair where I work. He is growing up fast, and with it, is a bit more careful and aware of the tech in the house, so we should be fine.

Is it speedier? Well yes, you can notice it in Xcode, but not by a huge amount. I do think, it will save a bit of time over the course of a year. The quicker the projects runs the better it is for you as a coder. If it takes too much time, you can break the flow. The Air still does a really good job with the M1 CPU, for the size and the price, the Air is still remarkable.

What else, I didn’t hear the fans yet, I suspect I won’t, with just a simple Xcode project. I do expect to hear them when I work on some ML models, will see. Obviously, if there were no fans, there was no heat.

The screen is really nice, and feels just the right amount of size for what I need. Not to small, not too big. Like all Apple screens, it’s comfortable to look at, and while I don’t necessarily work outside in the daylight, I do like that I can bring it with me and while the kids have fun outside, in grandma’s yard, I can work on my projects. I suspect this to happen during the summer days.

Moving stuff to the new machine was pretty easy, and installed all the stuff I need to code, and left other programs on the Air, like for example, Minecraft (education) that I play daily with my oldest son.

The sound is really impressive, while I won’t use it much at home since I prefer my Bose speakers, the sound coming from the MacBook Pro 16 is not something you would expect from a laptop, really deep bass and clear and well balanced in the midrange.

I don’t think I will bring this one on trips with me, because it’s so heavy, and will probably prefer to bring the Air on trips where I only use the system for Photography, even if the MacBook Pro has an SD card reader and I have to carry additional connectors for the Air.

There is definitely room and uses (in my case) for both. Initially the plan was to give the Air to my big son, when he is going to start school in the autumn, but he prefers my older Lenovo Yoga with touch screen, that comes with a bigger screen than the Air. The other question might be whether to buy the Max or the Pro, and the answer should be given by your intended usage, if you mainly use the CPU and rarely the GPU cores, then go for the Pro, if you need the GPU’s then go for the Max.

Well that’s it for now, if you feel that you like the screen size, the MacBook Pro 16 2021 is definitely a good machine to code on.

Today I started coding (using Xcode) on the MacBook Pro 16 2021, here are my first thoughts