Xcode 4.2 Switching File Shown in Editor - xcode

When I run my code, Xcode switches from the file I was working on to main.m in the editor. It's driving me nuts. Any ideas?

In your menu bar at the top select
Xcode --> Behaviours --> Edit Behaviours
then select Show Navigator --> Current View
and
Show Debugger --> Current Views
Do this on any category that you feel may be triggering this behaviour.

like #Robotnik said, it sounds like you are crashing out for some reason. Look at the Console of your app within XCode and see if there are any exceptions or errors being thrown there?
And if that doesn't work, set breakpoints and step through your code and see what line might be causing the app to abort.
Crashes are usually the only reason I've ever seen for XCode to "magically" browse to main.m.

Related

Stop Xcode from switching to app delegate on SIGABRT

Whenever I get a SIGABRT error in my Swift project (if it matters, in this case it was because I was programmatically creating an invalid constraint), Xcode will switch to my app delegate file and highlight the first line of the class declaration as the source of the error. But there's never any useful information there - if anything, by leaving the code I was last working on, it's more likely to take me away from where the problem is. Is there any way to change or disable this behavior?
When you crash, Xcode needs to show you something that explains the crash. I don't know of a way to get it not to show you any source at all.
Currently, Xcode will select the lowest frame in the stack of the crashing thread that has debug information, and show the associated source. It seems odd that it is highlighting the class declaration, maybe that's where an implicit init method gets charged to or something? If this always selects a not relevant place, that seems worth a bug.
But even if the source location is relevant to the crash, I still like to keep my source editor windows from getting repurposed by the debugger. I do that by setting up a Run Behavior in the Xcode Behavior Preference pane that keeps the debugger in its own tab. Just set the "Pauses" action of the Running section to Show a named tab (like "Debugger"), and to show the Debug navigator in that tab. I also do that in the "Start" action. Then when the debugger stops I get switched to that tab, and can interact with the Debugger there, leaving my source editor(s) focused on whatever I was looking at when the debugger stopped.

How to return window state back to normal after debugging

When I run my project in Xcode a few things happen (especially if there was an exception)
The debug (output) window slides up into view
The file directory pane on the left switches to the Debug navigator
The code file you left off on switches to main.m or some other file where the error happened.
That's all great, but when I'm done running the application none of this goes back to how it was. So that means there's this constant repetition of hiding the output window, clicking on the file directory icon, and finding the file I was just on.
This is just completely unacceptable as I may run the application a dozen times in a minute.
Coming from Visual Studio, the same experience happens when debugging, but everything returns back to normal when you stop debugging.
How can I make things return back to normal?
Assuming you're using Xcode 4 or later, you can set up behaviors to set up things how you want. Under the Xcode Preferences, click on the Behaviors tab and select "Completes" under the "Running" section. You have the option to open or close any of the various panes.
Here's an interesting article on customizing Xcode to make it work better for you.

Xcode 4.3.1: Doesn't show me line of code when: Terminating app due to uncaught exception

In previous versions of Xcode, when I ran into a crash (does not respond to selector, or array index out of bounds, etc) Xcode would usually open the file where the crash happened and often take me to the line where it crashed. The latest Xcode doesn't seem to be doing that which is making debugging a LOT harder.
Do I need to enable some new settings or something? I just downloaded the latest version 4.3.1 and I created a new project so the project settings should hopefully be the right defaults.
You can try this: http://blog.manbolo.com/2012/01/23/xcode-tips-1-break-on-exceptions
Summary: it can be helpful to add an exception breakpoint, which breaks when an exception is thrown, rather than when it is caught. In order to do this, go to the breakpoint navigator pane, click on the + in the bottom left corner, choose "Exception Breakpoint" from the popup menu, and accept the default settings. Note: despite being an old tip, this still works on Xcode 8 in late 2016.

Xcode doesn't open a project normally

I'm using Xcode 4.1 and it has always worked perfectly but today something wrong has happened. Instead of opening my project as it usually does it opens just code editor and nothing else. I have restarted my computer but it doesn't help. Other projects are opened normally. Can you give me a hint about what's going on and what should i do to fix it?
View --> Show Toolbar ,
View --> Show Assistant Editor ,
View --> Show Project navigator
and so on.
The solution, as others wrote before, is to reopen the missing panes and toolbar via the menu.
The cause of the problem is simple: If you open a source file in its own window (by double clicking it in the navigator or so) it just shows the editor pane. if you then close the main project window and the single source window afterwards, Xcode saves that last window state as the current view configuration in the project.
The intermediate solution is to never close the project window before closing all other source windows. But Apple should really fix this stupid bug. It has been around for too long.
Go to
View --> Show Toolbar.
I've had this before, don't know how it happened, but this fixed it.

IntelliJ 10.5.2 on Mac OS X Lion: Command-Option-L stops working

This is just plain weird.
For some reason, the accelerator Cmd-Opt-L (reformat code) no longer works inside IntelliJ 10. This started with one of my projects and seems to have "spread".
Other accelerators work normally. Reformat works if I use the menu to select it, or Cmd-Shift-A and choose it from the "Find action ..." popup dialog.
I've tried to see if some conflicting application is the cause. I'm using 1Password and it defines an accelerator for Cmd-Option-L, but I disabled that, restarted IntelliJ and still no dice.
A quit-and-restart doesn't help.
More oddness. I pulled down the Code menu and typed Cmd-Opt-/ ... I can see the menu item flash and then my editor updates. If I pull down the Code menu and type Cmd-Opt-L, there's no reaction (the menu line for Reformat Code does not flash, the menu stays up). So ... one theory is that something elsewhere on my Mac is consuming the Cmd-Opt-L before it gets to IntelliJ? If that's so, how would I track it down?
Your theory is correct. As a workaround you can remap reformat code action to different shortcut in Settings | Keymap.
As for tracing the offending application, I'd try killing one by one and see when it starts working again.

Resources