MacOS SwiftUI app hangs after view creation

Recent changes to my macOS swift app have caused it to hang before the window appears, and the app is unresponsive. Before those changes it came up but seemed slow, which I attibuted to view creation taking time.

I've put some logging into the new creation, and I see that the views are created quickly, so something seems to be really slow, or in an infinite loop after that.

I've tried running instrumentation to figure out what is going on here,

I'm open for suggestions on what to do.

Replies

I've tried running instrumentation to figure out what is going on here,

Do you mean you profiled the app with Instruments? If so, what templates did you use?

I recommend profiling your app with Instruments. Choose Product > Profile in Xcode to profile with Instruments.

The App Launch, SwiftUI, and Time Profiler Instruments templates will help you find what's taking so long. The App Launch should help if the slowness you're experiencing occurs when launching your app. You may also find the following article helpful:

https://www.swiftdevjournal.com/finding-the-slow-spots-in-your-code-with-the-time-profiler-instrument/