UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

App sometimes crashes on launch since Monterey

Forums > macOS

Hello, I've got a strange problem with a published app since Monterey came out that I've only noticed now. The app basically crashes right after launching but not quite all of the time, just most of the time; the icon doesn't even have time to fully appear when it does crash.

If the app hasn't been opened in a while it seems to launch correctly most of the time though. Additionally, as strange as it sounds, it is much more likely to launch correctly if you open the app from the Launchpad rather than the finder.

The error messages I get from Xcode when I launch from there is:

_TSGetMainThread_block_invoke:Main thread potentially initialized incorrectly, cf rdar://problem/67741850

Unable to load nib file: Main, exiting

Has anyone else seen anything like this? The app uses Core Data with CloudKit.

4      

Having the same issue here, did you get anywhere? Also using Core Data with CloudKit.

4      

I've encountered the same issue in a SwiftUI macOS app, also using Core Data and CloudKit. My NSPersistentCloudKitContainer got initialised right when my App subclass got initialised. I figured that might be the cause. I've changed that to a lazy var and haven't seen the issue since. Hope that helps!

4      

I hit the same issue again half a year later. I had added code which accessed the persistent container right on app start-up again, resulting in the same crash. This time wrapping those calls in DispatchQueue.main.async { ... } did the trick. Alternatively, calling out to let _ = NSApplication.shared in my App.init() method also does the trick. I've filed this as FB10902789.

3      

Hacking with Swift is sponsored by RevenueCat

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.