GO FURTHER, FASTER: Try the Swift Career Accelerator today! >>

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 try! Swift Tokyo.

SPONSORED Ready to dive into the world of Swift? try! Swift Tokyo is the premier iOS developer conference will be happened in April 9th-11th, where you can learn from industry experts, connect with fellow developers, and explore the latest in Swift and iOS development. Don’t miss out on this opportunity to level up your skills and be part of the Swift community!

Get your ticket 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.