Xcode 6.3 shows random files instead of counterparts in assistant editor - xcode

I always have my Xcode assistant editor open with counterparts option. It's very handy to have an *.m file opened at standard editor while having corresponding *.h file in assistant editor.
After recent update to version 6.3 Xcode started to show random instead of corresponding headers quite often. Several clicks to "four squares" icon and mode usually brings it back (but it's very annoying).
Do you experience this too? How to fix it?
Note: deleting DerivedData didn't helped

As a workaround, one could use the Reset Editor command with the keyboard shortcut Command+Option+Shift+Z (US keyboard layout). If your keyboard layout doesn't match, you can see the key binding in View->Assistant Editor->Reset Editor. A word of caution, though, this will close any additional Assistant Editors you may have opened (the ones that open by clicking "+").
Another thing I noticed is the bug happens when you are switching Xcode windows or tabs but not when you are switching files within the same tab.

It looks like it's a just bug after all. I filed a bug report rdar://20684654. For a workaround see the accepted answer.
UPDATE: it's fixed in Xcode 6.4 beta

Related

How do I build an Xcode shortcut for frequently used code snippet? [duplicate]

When I follow all the instructions (including apple's video) to drag text to create a code snippet in xcode, I get a different system behavior: all I see is the selection ibeam... I can't drag. It just ends up selecting text again. Am i missing some obvious Apple-ism?
Thanks
Yes, I ran into the same problem, and Apple-ism seems to be a good term for this issue :)
It works this way:
Select (or highlight) the code your want to turn into a snippet
EDIT: Click and hold (do not drag!) on any part of the selected text for a short moment (like 2 seconds, sometimes 8 seconds)
EDIT: The mouse cursor will change icon (not on El Capitan).
Now you can drag the code over the snippets library, where a green + icon will appear. EDIT: On El Capitan the green icon does not appear, but the frame of the code snippets window will become thinner.
This happened to me as well. The given solution didn't work but still needed to create snippets.
This is a workaround although not the best option, it works.
From Xcode, select the snippet window, and leave it selected.
Open a text editor app.
From Xcode, select and copy the code you want to use to create your snippet.
Paste it into your text editor and then select all of it.
Now drag&drop normally from the text editor into the snippets window in Xcode.
As said, not the best option but it works.
(Note for Xcode 8.1) Sometimes selecting the text and maintain the mouse button clicked for 3..8 seconds the cursor turns into an arrow and it's possible to D&D. Too bad it only works sometimes...
On High Sierra 10.13.3 and XCode 9 I faced the same problem. The decision that works for me is selecting code on a blank space before the first symbol and then dragging it to the snippets library.
Important: you need to drag only from the blank space (look at the screenshot below). Otherwise you will reselect your code again.
The cursor changes only when you start dragging, so don't be confused and don't wait until it changes.
I've run into this problem with Xcode 7.2 on Mac OS X 10.11.2 (El Capitan). Click and hold on the selection and the cursor never changes from the I-beam to the arrow for dragging.
Although MLBDG's answer is a usable workaround, I found that quitting and restarting Xcode fixed the problem. This might not work for everyone, but it's worth a try if you're having difficulty.
just highlight your text
copy in filter text field that u can see on your bottom of snippet library
paste the text
now select the text and drag from there to snippet library
The answer is really !undisobvious. You need to select a chunk of text. Then click on actual text characters, but without moving the mouse. Only then will the gods of XCode bequeath unto you a draggable snippet of code to do with as you please. Should you dare to miss the text and click in empty but selected space, the demons of XCode will strike down your selection and make you start from scratch. The unfortunate will not even realise this feature actually exists.
Hold option to duplicate it. For instance to make a duplicate case statement without destroying your copy buffer, then replace the case you cleverly have ready to paste during your search.
As a UI designer it is not obvious to me why this has such an unreliable twitchy implementation.

Windows Octave fails to paste text from clipboard?

I am just install Octave 4.2.0 in Windows 10 and try to do some Machine Learning exercises. I notice that I can't paste the normal clipboard content to the Octave.
Does anyone else have this issue? If so, any work around? Or is it just bug in the program?
Although your description doesn't indicate the exact place you're trying to paste contents into, there were a couple bugs around the time of Octave 4.2 specifically related to this problem. See:
bug #51095: editor doesnt allow paste of exisiting clipboard data
and
bug #52361: Ctrl-C/Ctrl-V only works reliably if executed as very first action
both bugs have since been patched and closed (around version 4.4), and reports seem to indicate that the problem has not resurfaced in later versions. Anyone experiencing similar issues in a recent version of Octave (v5.2.1 as of today) should either comment on one of those closed bug reports or create a new one at https://bugs.octave.org
Run >> preferences, and in the Shortcuts tab, untick the option at the top "Disable global shortcuts when Command Window has focus". (I don't know since what version it is there.)
If you disable global shortcuts, Ctrl-V (for paste) is disabled because it is a Windows thing.
If you do not disable them, Ctrl-V will work. So will Ctrl-C to copy text, but it will also still work to abort an execution.
If you click on the icon in the title bar on the top left corner of the
window, you'll get an edit option, and you can choose to mark (choose
the text to copy), copy, and paste from there.

How can I make the tabs work normally on Xcode 4?

Xcode finally added tabs but the problem is that they behave very strange. For example they will keep a tab open only if it was opened to a new tab.
If you open a file just by clicking in the project tree, Xcode will close your tab as soon as you are clicking on another file in the tree.
Is is possible to make them behave like real tabs and prevent Xcode from reusing them? How?
I use a method similar to franks:
In Preferences > Navigation (or Preferences > General in versions of Xcode prior to 5) you can set Optional Navigation to Uses Separate Tab
Now opt-clicking a file in the file navigator will open it in a new tab
Better yet, opt-clicking links in the code opens the destination file in a new tab
The big feature missing is swapping to an already open tab containing the file if there is one (or staying in the current one).
UPDATE for 2020:
Finally, almost 10 years later, Xcode 12.x now appears to mostly resolve the issue described here. There is a new Navigation Style option in the Navigation settings panel that controls this behavior.
The behavior has some new quirks/design-choices that seem to make sense, but I'm still getting used to the new experience. For example, a tab will get re-used unless the file in that tab has been edited recently; such a tab is indicated with an italics title.
PREVIOUS ANSWER
I don't think you can currently get the behavior you desire (or I desire). While the tabs work like Safari, they don't work like tabs in other popular IDEs (Visual Studio or Eclipse). And for me this kind of sucks.
In general, I expect IDE tabs to keep more than 1 file open. So if I click a file in the project tree, I expect that it will switch to the tab I have opened with that file - if I have already opened it. Instead, XCode 4 changes the current tab to the file I clicked - making 2 tabs with the same file. Having 2 tabs with the same file is fairly useless.
This forces the user to scan the tab bar first to see if the file is currently opened; if it's not opened then you can look to the project tree. But if you click in the project tree first (which is what I tend to do) then you get punished because you will have just killed a tab.
This isn't really an answer insofar as it contains a solution; I mostly just want to join in the griping. But upvoting will make you feel better and prove Apple wrong. :)
The problem with Xcode 4's implementation of tabs is that Apple has implemented them as workspace tabs. In other words, creating a new tab essentially creates a new workspace, each with its own sub-panes with their configurations, etc. It's essentially a whole environment in each tab. There are a number of problems with this choice.
This differs from most IDE/text editors' implementation of file tabs wherein a tab (generally) represents a single file, and each file has its own tab.
The problem with workspace tabs is there are only so many potential different workspaces we could benefit from, severely limiting the actual use of tabs in this way. Beyond this, the additional workspaces just become a liability, introducing more things the user of the application needs to concern him/herself with: for example, what the navigator view is, what editor mode is active (standard, assistant, version), whether the debug console is open, etc. etc. Suddenly switching to a new tab means you now have to worry about getting the environment back in the form you need it, because there's a good chance the other tab wasn't left in the state you expect to find it in. This actually discourages the use of tabs because it introduces more work in the workflow.
File tabs don't have this problem (not counting special cases like split view panes) because all that's changing is the file you're looking at, not your whole environment. Moreover, if implemented properly, file tabs work great as an immediate history, allowing one to quickly switch back to a file that was worked in recently, with little effort. The only way to do this in Xcode is to explicitly set up a new tab environment for each file you want to work with, but you have to be careful not to change the file in that tab or your file all of a sudden becomes lost: again, more work for the user.
Workspace tabs are also significantly heavier-weight than file tabs, because there is much more to remember and switching workspaces involves much more than switching files.
The truth is (and I think most will agree with me on this), to a developer, file tabs are much more useful than workspace tabs, and as it stands Xcode still lacks a proper implementation of this feature that many would consider basic required functionality in an IDE/editor.
Xcode->Preferences->General->Double Click Navigation and from the list, choose Uses Separate Tab.
Well, not a real answer but my personal workaround. The real problem for me is, that a file opened in a tab goes away so easily in xcode 4. Finding a file again can be time-consuming, so I like them to be in a tab and stay there.
I solved this (somehow) for me by exactly identifying the actions I do which cause the tab to switch to another file and replace them by their equivalent actions which open a new tab instead.
Instead of single-clicking a file in the navigator, I always double-click which I have set to open a new tab
Most time I do not use the navigator, as it has a different state of opened and closed folders in each tab. Not useful for me. So I switched to using Option ⌥ Command ⌘ O. When opening a file from this list I keep ShiftOption ⌥ pressed. In the small window appearing I choose 'new tab'.
When clicking on links in code I press ShiftOption ⌥ Command ⌘, too, and open in new tab.
I keep two fixed tabs around for editing target-related settings and to view build results. I completely disabled all automatic tab switching in the prefs, because I noticed this distracted me to much.
I would really love to get something like the xcode 3 favorites bar in xcode 4, this was so simple to use..
I imagine my answer won't bubble up for a while, but if you want this to work like visual studio or intellij (or at least closer)
Preferences->General->Double Click Navigation->Uses a separate tab
Double Clicking a file now will stop opening it in a new window and open it in a new tab.
Single is still dumb and takes over your tab. But if you get used to double clicking (which I was already) this will save you some headaches. I suppose.
I absolutely hate how tabs work in Xcode. However, the only workaround i found that works decent is using the OSX tabs shortcuts:
CTRL + CMD + ->
CTRL + CMD + <-
I found my way in Preferences-Behaviors!
I hated Xcode 4 first for the tab issues discussed here, mainly because the debug information kept opening new files in tabs and changing the navigator
in Behaviors you can define a Debug tab and make the Run and Build jump there in various ways. in the Debug tab I give more space to navigators left and bottom
for similar reasons I have a Find tab, too
the other tabs are for files I am writing in. I start them with the .h which is usually small enough so I need only one view, and then with single clicks in the navegator I open 2-3 versions of the .cpp file so I can set them to the locations where the recent hot spots in the file are. then I close the navigators in those tabs
this does not invalidate the care and tricks given in the other answers here, but makes them far less hard
happy coding!
I found out that when pressing option a.k.a. alt when opening files in the navigator, you will jump to the tab already open with the file and a new tab will open in case it was not yet open.
This technique also works when opening files via cmdshift-O and opening the suggestion with option-enter in stead of simply enter...
Now, if there would be some way to make this the default, i.e. the need to keep pressing option all the time would be removed, that would be a big step forward.
Also I use Behaviors to keep my tabs from being recycled after test or build failures.
(Like other people, I totally mislike Xcode's tab behavior. Apple should take a look at IntelliJ...)
xcode tab bar is so suck, I think Apple should enhance the feature of the tab navigation to avoid followed 3 points.
1. double click a file will let xcode open another tab if it has already been there.
2. for more tabs, the tab will become small and thus I don't know which file in which tab, I want the tab show full name
3. for even more tabs, new tabs will be hidden, instead of two lines of tabs. I want to it show two lines of tab bars.
If you have the tab bar enabled (View/Show Tab Bar) and you double click a file, it appears in it's own window, with a single tab (Be sure the Tab Bar is enabled in both the new and old (main) windows).
Now all you have to do is drag that new window from its tab and drop it into the tab bar of your main window.
It will stay docked as a separate tab, showing that file.
To change the file open in that new tab, go Project / Reveal in Project Navigator, which opens the project navigator at the left hand side.
Tabs in Xcode 4 work like tabs elsewhere on Mac OS X, for example in Safari and Terminal.

Multiple editor windows

One feature I found missing in earlier versions of Xcode 4 was opening an editor as a separate window. Has this feature been put back?
I don't want to go back to MDI hell.
In the Xcode preferences window, under general, there is "Double click navigation." You can set that to use a separate window or a separate tab.

Multiple editor windows in Xcode

When coding in Xcode, I double-click a file in the "Groups and files" list, and it opens a new editor window. I have several of these open at once.
Until today.
Today, when I double-click a file in the list, it opens the file in the last editor window I was using, meaning I can only have one editor window up at any one time.
I guess I've switched some option somewhere by mistake. How do I get it back to the way I like it?
I'm using Xcode 3.2.5
In the top right of the editing window is an icon that says "grouped", perhaps you clicked on it by accident.
Click on it so it says "ungrouped", and you'll be back to opening multiple windows.
perhaps preferences>General>Open Counterpart in same Editor

Resources