Running my app from Xcode today I got this scary log:
!!! BUG: The current event queue and the main event queue are not the same. Events will not be handled correctly. This is probably because _TSGetMainThread was called for the first time off the main thread.
App got stuck, its window never appeared. Not sure what to make of it. Ran the app like 3-4 times and still got the same log. This app has been around for awhile never seen this before. Now all of a sudden, this no longer is logging out and the app is working like normal again with no code changes?
This can happen if you spin up a worker thread from your main() or somewhere else that's very early in app launch, and the worker thread winds up calling into the event system prior to when the main thread calls -[NSApplication run]. Essentially, the thread that makes the first call to the event system winds up marking that thread as the main thread.
You might try debugging by setting a breakpoint on _TSGetMainThread (which is in CarbonCore.framework, but you don't need source to set a breakpoint; just add a symbolic breakpoint) and then launching your app. If your breakpoint is hit and the backtrace is for a thread that doesn't start with NSApplicationMain, then you have found your culprit.