With a dark color scheme in Xcode 4 the i-beam cursor (aka text selection cursor) is nearly invisible. Is there a way to change the color of this cursor, either for Xcode specifically, or failing that, system-wide?
It'd be nice if it would automatically change to a color contrasting its background too.
As of Xcode 8, Apple has hidden the i-beam cursor somewhere where nobody has found it. Instead, many have chosen to use Mousecape to alter the i-beam in all programs. I prefer that method since it fixes the i-beam in other programs that support dark themes, such as Komodo editor. Mousecape should work in all Xcode versions and updating Xcode won't break the cursor. I'm currently using Mousecape in macOS 10.13.2, Xcode 9.1. Here are the steps:
Download Mousecape from here
Download a "cape" with modified i-beam cursor such as Bright white or Grey shadow
Run Mousecape.app
From Mousecape's menu bar: File > Import Cape > "cape" file downloaded above
Right click imported "cape" and choose Apply
Check the new cursor is working in Xcode. When satisfied, you can apply the cursor on each reboot by running a command from Mousecape's menu bar: Mousecape > Install Helper Tool
Installing macOS updates (such as 10.13.1 to 10.13.2) may require repeating steps 5 and 6.
Original answer:
Xcode does NOT use the system-wide i-beam cursor as everyone I found talking about it stated as if it was a known fact. If I hadn't believed those people, I wouldn't have spent two days figuring out how to alter the system i-beam cursor by editing CoreGraphics only to find that Xcode's ibeam doesn't change.
BTW, I also stumbled on how to edit other system cursors.
I spent most of a weekend figuring this out, but the i-beam cursor in Xcode CAN be edited. It's simply a TIFF file in the following location for Xcode 3.2.6 (and earlier, I assume, but have not tested):
/Developer/Library/PrivateFrameworks/XcodeEdit.framework/Versions/A/Resources/TIbeam.tiff
Xcode 4.1 has the same file but it does not affect the i-beam in the main editor (I assume it's used somewhere, but maybe not). Instead, the main editor in Xcode 4.1 uses this file:
/Developer/Library/PrivateFrameworks/DVTKit.framework/Versions/A/Resources/DVTIbeamCursor.tiff
The ibeam files have moved again in Xcode 4.4:
/Applications/Xcode.app/Contents/OtherFrameworks/XcodeEdit.framework/Versions/A/Resources/TIbeam.tiff
/Applications/Xcode.app/Contents/SharedFrameworks/DVTKit.framework/Versions/A/Resources/DVTIbeamCursor.png
/Applications/Xcode.app/Contents/SharedFrameworks/DVTKit.framework/Versions/A/Resources/DVTIbeamCursor#2x.png
Editing DVTIbeamCursor.png was enough to change the i-beam in the main editor on my system. On another site, someone reported that DVTIbeamCursor#2x.png will be used on a retina display or Apple's other new high res displays like Thunderbolt and Cinema. Who knows if TIbeam.tiff is even used anymore since they didn't update it to png.
According to comments below, in Xcode 5.0.2 all 3 cursor files were replaced with one file:
/Applications/Xcode.app/Contents/OtherFrameworks/XcodeEdit.framework/Versions/A/Resources/DVTIbeamCursor.tiff
And in 5.1.1 (boy, they sure love to change things in almost every version, don't they?):
/Applications/Xcode.app/Contents/SharedFrameworks/DVTKit.framework/Versions/A/Resources/DVTIbeamCursor.tiff
I'm guessing that file is a double resolution (aka retina display) cursor that's scaled down for non-retina screens.
If you can't find the ibeam file in your Xcode, try running this command in Terminal:
sudo find / -name 'Ibeam' -print
In Xcode 7.3, the cursor was moved inside the following bundle file so the search command above won't find it:
/Applications/Xcode.app/Contents/SharedFrameworks/DVTKit.framework/Resources/Assets.car
I recommend using a process found here to patch a new cursor into the bundle file. If you don't like the cursor it installs (I felt it was still too dark and the grey outlines blend in with grey comment text), follow these steps:
Download the latest release of Theme Engine (I successfully used version 1.0.0(111) with Xcode 7.3.1)
Back up /Applications/Xcode.app/Contents/SharedFrameworks/DVTKit.framework/Versions/A/Resources/Assets.car
Copy Assets.car somewhere where it can be edited, such as to ~/Documents/Assets.car.
Run Theme Engine.app, click Open Document, then open ~/Documents/Assets.car.
Scroll down the list of items on the left and pick DVTIbeamCursor.
You should see a normal resolution and double resolution ibeam cursor image in the center panel. Drag your own ibeam image on top of either cursor and it should change to show your image. I used a PNG image.
Save, then close Theme Engine.
Move your modified Assets.car back to /Applications/Xcode.app/Contents/SharedFrameworks/DVTKit.framework/Versions/A/Resources/Assets.car and keep a backup copy of your modified version somewhere so you don't have to do this again until a new Xcode version changes what's in Assets.car.
You may also wish to send an angry letter to Apple to complain that they have not fixed this problem in the last 7+ years and have instead made it progressively more difficult for users to patch Apple's broken cursor.
Don't forget to keep backups of your edited cursors. Newer Xcode versions will overwrite your custom cursors with default ones when it does a software update.
Here's the ibeam cursor I use: Right click the ibeam and choose to save the image to get the png version, or click here to download the tiff version.
If you're making your own cursor, notice that where the black lines intersect in the original cursor is where the white lines intersect in my cursor. That's because the original cursor was meant to be used on a white background, so its black part is where the cursor hotspot is.
I created a public repo for an ibeam cursor that should work on light and dark colored backgrounds, because it is black with a white outline. It includes succinct instructions, and a TIFF file ready to drop in to the Xcode bundle.
Update: the git repo includes a shell script that makes installation quite easy.
Unfortunately this is a difference between Carbon and Cocoa cursors—Cocoa cursors won't invert; at least, up to Snow Leopard. In Lion, even Carbon cursors behave like you don't want.
If you've got a machine running Snow Leopard or earlier, compare the I-beam behavior in BBEdit or TextWrangler (which use Carbon cursors), for example; it'll become entirely white on a black background. Even this is a bit fragile—when I change the screen magnification, BBEdit's formerly-white cursor becomes black.
You can still set a Carbon cursor in your Cocoa app. Try this in a NSTextView subclass:
#import <Carbon/Carbon.h>
[...]
- (void)resetCursorRects;
{
// disable existing cursor setting behavior
}
- (void)cursorUpdate:(NSEvent *)event;
{
SetThemeCursor(kThemeIBeamCursor);
}
- (void)updateTrackingAreas;
{
for (NSTrackingArea *trackingArea in [self trackingAreas])
[self removeTrackingArea:trackingArea];
NSTrackingArea *trackingArea = [[NSTrackingArea alloc] initWithRect:NSZeroRect options:NSTrackingCursorUpdate | NSTrackingActiveInKeyWindow | NSTrackingInVisibleRect owner:self userInfo:nil];
[self addTrackingArea:trackingArea];
}
(In 64-bit you'll see that this function is excluded from the headers, but the symbol is there and works.) If you're sufficiently motivated, you could potentially patch Xcode to do some variant of the above, perhaps from an Xcode plugin.
If you're on Lion, here's what it is supposed to look like:
So I'd suggest filing a bug with Apple to make the systemwide I-beam cursor (or NSCursor in general) properly handle dark backgrounds; it's not an Xcode-specific issue and it should really have been fixed years ago.
For Xcode 5 preview, i have created a better I-Beam for Dark color templates. You can use it freely.
http://www.scigems.org/wordpress/?p=92
According to this thread on the Apple forums:
https://discussions.apple.com/thread/2811447?start=0&tstart=0
the "cursor color" referred to in the XCode 4 fonts and colors preferences is actually the cursor you see when you have clicked in a window to enter text.
The I-beam cursor you see when you are moving the mouse around in the code editing window is a Mac-OS wide feature which you cannot change in XCode.
The forum post above suggests looking for third party software to change attributes of the system-wide I-beam cursor.
Another post points out that you can at least edit the cursor size to make it more visible:
System Preferences -> Universal Access -> Mouse & Trackpad -> Cursor Size
Related
In SwiftUI tutorial (link) it says to:
Command-click the text view’s initializer to show the structured editing popover, and then choose Embed in VStack
However, it does not work for me.
What is the command for that?
What that deprecated already?
If it helps someone out there, you must have changed Xcode shortcut preferences to go to "Definition" on "Command Click".
So now for seeing the structured editing popover, use "Control Command Click".
Seems to be an Xcode quirk caused by having the canvas hidden. Bring the preview canvas back on screen and the Command + Click functionality returns to normal:
I've seen similar weirdness with two Xcode windows open… especially if one window is hiding the Preview.
Another quirk mentioned above: the Library picker is missing the Views and Modifiers tab sometimes. Again, open the Preview Canvas and the Library will snap back to normal. You might also have to bring focus to the canvas (i.e. click on something there).
Close and reopen Xcode should help. Like code completion sometimes is not working the popover also sometimes stuck.
I found that command + Left Click on Text (within the .swift file) took me to the definition of Text, however command + Right Click caused the menu containing "everything" to appear, from which I was then able to select "Show in UISwift inspector".
I couldn't get anything to popup in the Canvas.
Using Xcode 12.2 on macOS 11.0.1
According to Apple's release notes for the latest Xcode 11 beta release, the inspector and preview features don't currently work without MacOS Catalina 10.15 (the current stable/public release is MacOS 10.14.6 at the time of posting).
You'll either need to wait until the publicly released version of Mac OS 10.15 or gain access to a beta version of MacOS to use these.
Source (Apple | Xcode 11 Release notes):
Xcode 11 supports development with SwiftUI. (22843503)
Note: SwiftUI previews and inspectors are only available when running on macOS Catalina 10.15.
Restart the project for 1 or 2 times and CMD+B(Build) your project one the start.
Please note that I am not asking about Ctrl+Dragging. That is a different issue. I am asking about regular dragging, i.e. moving a text field around in my Main.storyboard file.
I can click on an object to bring up its little white boxes around the corners and sides, but I can neither drag around the object nor can I use the little white boxes to change the object's size.
I am using VNC Viewer on a Windows 10 platform and connecting to a Mac with version 10.11.6. On the Mac, I am using Xcode version 8.2.1 (8C1002).
I am new to programming on the Apple Mac. I have followed a programming guide supplied in the Mac Developer Library to program a basic GUI program called TrackMix. In this program you place a textbox, a vertical slider and a button control on the view window. Initially, on dragging the specific object, say the textbox, to the window, a set of alignment guides (dotted blue lines) would automatically appear on the canvas when the object is dragged over it. I dont know what has happened, but now those guides have disappeared when I execute the same action of dragging objects to the window. When the object being dragged is over the window a small green dot, with a plus sign in it, appears on the bottom of the object. I have carefully retraced my steps to be exactly the same as stated in the Developer Library, but still the problem persist. Have I, perhaps, involuntarily changed some Xcode settings or what? I am at the end of my wits! PS: I am using Xcode 7.
You have to toggle the menu item "Editor > Canvas > Snap To Guides" in Storyboard. I hope that helps
I am not sure whether this will be helpful, but I just had the same problem and the only thing which worked was re-installing Xcode (7.3) and trashing all of the Xcode preferences.
Good luck.
Firefox 31 has changed my web console layout and I can't find the option to change it back. Being that I have a widescreen monitor I prefer the console to the right. When I select an array/object to view it opens it in a split as expected, but ever since the update I can't get the split to stack them vertically so they can use more width. Am I just not seeing this option?
Update: For Firefox up to v33 use this plugin, for 34+ behavior has changed. Read this thread on Bugzilla for details: https://bugzilla.mozilla.org/show_bug.cgi?id=1084004
This was added in Firefox 34, now in Beta. It is not in Firefox 33, the current release.
If you have the toolbox docked to the side, the Object Viewer pane will automatically drop to the bottom if the toolbox gets too narrow, see this gif for a visual example:
No, you are not missing the option. The option does not exist.
However, here is a quick-and-dirty extension that does what you want for Firefox 31.0 through 34.0:
http://www.mediafire.com/download/oxt4c5o5vypca85/place-webconsole-object-view-vertical%40makyen.foo.xpi
I tested it on Firefox 31.0, 32.0.1, 32.0.2, 33.0b4 (current beta), and 34.0a2 (Aurora, the current alpha). All of them worked. The file the extension changes, webconsole.xul, has 4 slightly different versions in that range of Firefox releases. One of the changes was between 32.0.1 and 32.0.2.
I had another extension for which I was already working on a similar set of compatibility and testing and then Mozilla released FF 32.0.2 today. Leaving this solution as only compatible for 31.0-32.0.1 just didn't sit well with me, so I did the mods to give it the wider compatibility range.
In 34.0a2 the stock behavior of this part of the webconsole is a bit different. The object view automatically shifts from vertical to horizontal depending on how wide the devtools sidebar is. Visually, this is similar to how the inspector behaves in 31.0 (and later). The above extension, when installed on 34.0b, will lock it in the vertical position. Personally, I really don't like the auto-choosing of vertical/horizontal. I would want a control and be able to lock it the way I want it when I am viewing it. This is not supposed to be a glitzy wiz-bang UI thing to get the masses interested. This is a: I want to get my work done now and I want it my way because that's how I work fastest/best. Sorry, I got up on my soapbox there a bit.
It's the icon that has a rectangle at the bottom. In your case (Where the yellow arrow points):
Xcode 4.2 used to toggle between the header file and the .m file when you swiped up/down with 3 fingers in an editor window. Now excode 4.4.1 turns it into a text selection. Is there a way to change the default behavior to something else (in my case back to toggling between .h/.m)?
I got the 3 finger swipe working in Xcode 4.4 (I'm running Mountain Lion). It is possible. Try following these instructions: https://stackoverflow.com/a/7923619/472344.
I had already used these to get the 3 finger swipe working in Xcode 4.3 when I updated to Lion. It seemed to break when I updated to Xcode 4.4 and Mountain Lion. I went through all the steps again, but this time all the settings were already set correctly so I didn't have to change anything. However, now it's working for me. Give it a shot.
You can also switch between the .h and .m by using ctrl+command+UpArrow (or DownArrow).
I don't know if there is a way to change the gesture within Xcode, but usually i find if i open .h first, then .m (or the other way around) then you can swipe between them with 2 fingers right or left :)
As long as you open them in the centre and not in a new window =]