Leveraging SF Symbols from code

SF Symbols are hugely helpful to help accelerate the development process, Apple has done an amazing job at providing a huge variety of them – all looking great & working well with one another.

If you’re a developer and are not familiar with them, you’re missing out – go download them

One minor caveat to be aware of though is that you can’t just call the Unicode codepoints. As I learned today, these will not work unless you have the design fonts installed.

So, for instance this…

Screenshot 2023 02 26 at 10 52 44 AM

 

…will not render. Wops!! The right way to call it would be:

Screenshot 2023 02 26 at 11 05 26 AM

 

Alternatively, you could also use Label(“someText”, systemImage: “flag”) 

Screenshot 2023 02 26 at 11 15 58 AM

Happy coding! Comments / Feedback? Find me at mastodon.social/@MarcMasVi or @MarcMasVi

Marc

Microsoft aggressively capitalizing on their OpenAI investment

There’s a lot of chat right now about ChatGPT. And, although the technology may be a bit overhyped, some of the use-cases it enables have the potential to change the way we work:

 Here’s one, from the Verge: 

“Intelligent recap is the big new addition to Microsoft Teams Premium […]. Intelligent recap uses OpenAI’s GPT-3.5 model to generate meeting notes and highlights even if you weren’t present in a meeting.”

https://www.theverge.com/2023/2/2/23582610/microsoft-teams-premium-openai-gpt-features 

Interesting times, 

Marc

The Last of Us – HBO

I was not expecting much from “The Last of Us” from HBO, after so many poor adaptations of video-games, what could one look forward to? Well, I’m glad to say I was wrong. 

The first two episodes have been so fun to watch. If you enjoyed the game, do check them out. 

Faithful to the material too 🙂 Here’s hoping the rest of the season is as good as the first episodes. 

Marc

And just like that, MarsManaged has reached Beta!

After 18 months of work…

F3dbff58a2c8c907

…I’m excited to announce that MarsManaged has reached a major milestone, it’s now in Beta. 

In the following weeks I’ll be opening up more testing seats, can’t wait for your candid feedback -and bug reports-! 

Until then, here’s a sneak peak of the latest version of the app. 

CARD’s section:

Screenshot 2023 01 07 at 3 07 22 PMACTIONS section:

Screenshot 2023 01 07 at 3 15 11 PMThe way you do Product Management will never be the same 🙂 

Stay tuned! Comments / Feedback? Find me at mastodon.social/@MarcMasVi or @MarcMasVi

Marc

Easily linking any AppKit or UIKit class with SwiftUI

After spending an embarrassing amount of hours trying to get TextField to do what I needed on macOS I decided to try NSViewRepresentable + NSTextField.

I was fully prepared to spend the night on this… Yet I got it done in 30m 😮 

Lesson learned! Going forward, when a SwiftUI object is not mature enough I will not try to hack it with modifiers… Instead,  I will go straight to AppKit or UIKit. I know I’m loosing portability – which is why I spend so much time trying to do it all in SwiftUI – but, especially on macOS, SwiftUI sometimes is just not yet there. 

So, about linking to AppKit or UIKit… Online there’s a lot of, shall we say, over-engineered examples? Frankly, I believe it puts off a lot of people -including myself-, even though its actually very easy. 

Below is the leanest approach I found to link to any AppKit/UIKit class and their respective delegate. For this example I’m linking to NSTextField, but you could do it just as easily with any class.

Here’s how you call it from SwiftUI once implemented:

OSXTextField(textOfWhatToDisplay: someContent)

And here is the wrapper code for NSTextField, all self contained within a Struct:

struct OSXTextField: NSViewRepresentable {

 

    var textOfWhatToDisplay: String

    

    func makeNSView(context:Context) -> NSTextField{

        let osTextView = NSTextField(string: textOfWhatToDisplay)

        osTextView.delegate = context.coordinator       

//      osTextView.isBordered = false //example of calling NSTextField 

//      osTextView.drawsBackground = true //

        return osTextView

    }

    

    func updateNSView(_ nsView: NSTextField, context: Context) {

 

    }

    

    func makeCoordinator() -> Coordinator { //Called automatically by SwiftUI if implemented, used to trigger delegate

        Coordinator(parent: self)

    }

    

    class Coordinator: NSObject, NSTextFieldDelegate {

        

        var parent: OSXTextField

        

        init(parent: OSXTextField) {

            self.parent = parent

        }

        

        //NSTextFieldDelegate methods would go here

        

    }

}

 

This experience, all the hours I put into getting TextField to work, has also been a great reminder of the sunk-cost fallacy.

Comments / Feedback? Find me at mastodon.social/@MarcMasVi or @MarcMasVi

Marc

Here’s to 2023!

As Eisenhower said “Plans are worthless, but planning is indispensable”, so… In no particular order, my plan for 2023 is to:

1. Ship MarsManaged for macOS sometime before June, add iOS versions before EOY

2. Complete two more AI courses & tackle several problems that interest me where ML can make a significant difference

3. Read a book every month, summarizing it for later review in DevonThink (my second, and better?, brain)

3. Exercise & meditate at least 4 times a week 

4.  Find fellow indie devs in San Diego, where my wife and I recently moved

I’ll keep you posted on progress! Hope you all had an awesome end of the year and a great start of 2023!

Comments / Feedback? Find me at mastodon.social/@MarcMasVi or @MarcMasVi

Marc

 

PS. The GIF above is from The White Lotus, my wife and I really loved the show. 

Restoring macOS window after close – SwiftUI WindowsGroup

Typical behavior for macOS apps is that the apps will preserve their size and position when closed (Command + W) or quit (Command + Q) by the user. 

11sgE

 

When using SwiftUI & WindowsGroup that’s not the case though: although it works as designed when quitting, it forgets position and size when closing the window (Command + W).

I’m hoping this gets addressed in the future, but until then I’m using AppDelegate to intercept the close command and instead hiding the window. 

@main

struct MarsManagedApp: App {

    

    @NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate

    

}

 

class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate {

 

    func applicationDidFinishLaunching(_ notification: Notification) {

        let mainWindow = NSApp.windows[0]

        mainWindow.delegate = self

    }

    func windowShouldClose(_ sender: NSWindow) -> Bool {

        NSApp.hide(nil)

        return false

    }

}

Works like a charm, thanks to Mark G for the tip. 

Feedback / suggestions? Reach me at mastodon.social/@MarcMasVi or @MarcMasVi

Marc

Writing these lines from San Diego!

Some personal news to share, my wife and I have relocated to San Diego! 

We’re still in temporary housing, but I do expect to be fully settled starting January. Until then, I’ll be posting less as there’s a lot of things we’re handling ATM. 

So far, loving it here – here’s a pic from yesterday, just a few minutes from my temporary house. 

IMG 6291

And, yes, AvoToast scene is very much here. Approved!

IMG 7033

If you’re based in SD do hit me @MarcMasVi

Marc