TeXShop on macOS Golden Gate

Compiling TeXShop on Golden Gate

Compiling code on Golden Gate requires a new version of XCode, version 27.0 beta. That version automatically adds the latest version of Liquid Glass to the program. A couple of days ago, Apple released macOS 27.3, the latest beta. This document describes that release, and compiling code on it using XCode 27.3 beta.

Initially the Tahoe source code for TeXShop 5.57 refused to compile on Golden Gate. The first bug reported was that the minimal version of macOS which the code would support was Sonoma rather than the previously supported Big Sur and higher. The latest XCode only supports Sonoma, Sequoia, Tahoe, and Golden Gate. So this item was reset to Sonoma.

After that, a long list of errors were reported, all related to calls to various forms of [customView frame]. The problem was that many different classes defined such a frame element and XCode couldn't determine which should be called. This problem was fixed by revising a few lines of code in TSToolbarController.m. In makeToolbarItemWithItemIdentifier, the change was


else {
        /*
	[toolbarItem setMinSize:NSMakeSize(NSWidth([customView frame]), NSHeight([customView frame]))];
	[toolbarItem setMaxSize:NSMakeSize(NSWidth([customView frame]), NSHeight([customView frame]))];
         */
        [toolbarItem setMinSize:NSMakeSize(20.0, 20.0)];
        [toolbarItem setMaxSize:NSMakeSize(400.0, 400.0)];
    }

	return toolbarItem;
   }
and in makeToolbarItemFixedWithItemIdentifier the similar change was
{
    NSToolbarItem*    toolbarItem = [self makeToolbarItemWithItemIdentifier:itemIdent key:itemKey];
    [toolbarItem setView: customView];
    /*
    [toolbarItem setMinSize:NSMakeSize(NSWidth([customView frame]), NSHeight([customView frame]))];
    [toolbarItem setMaxSize:NSMakeSize(NSWidth([customView frame]), NSHeight([customView frame]))];
    */
    [toolbarItem setMinSize:NSMakeSize(20.0, 20.0)];
    [toolbarItem setMaxSize:NSMakeSize(400.0, 400.0)];
    
    return toolbarItem;
}
After these changes, only one error remained, in TSDocument.RootFile. See lines 186 - 195. In the routine CheckRootFile, a number of lines had to be commented out, as shown below.
} else if (task == RootForOpening) {
			// added by Terada (from this line) // This was moved here for version 2.40
			/*
             if([SUD integerForKey:DocumentWindowPosModeKey] == DocumentWindowPosSave){
				NSRect activeWindowFrame = [[obj textWindow] frame];
				NSScreen *screen = [NSScreen mainScreen];
				CGFloat minX = 20 + ((NSMinX(activeWindowFrame) 
					+ NSWidth(activeWindowFrame) 
				+ 20 > NSWidth([screen frame])) ? 0 : NSMinX(activeWindowFrame));
				CGFloat minY = (NSMinY(activeWindowFrame) 
				+ NSHeight([screen visibleFrame]) 
         			- NSHeight([screen frame]) + 20 < 0) ? NSHeight([screen frame]) : 
				NSMinY(activeWindowFrame) - 20;
				NSRect newFrame = NSMakeRect(minX, minY, NSWidth(activeWindowFrame),
		 		NSHeight(activeWindowFrame));
				[[obj textWindow] setFrame:newFrame display:YES];
			}
             */

Martin Hairer

On the first day of the developer conference, before I even downloaded the 27.0 release, Martin Hairer (martin.hairer@epfl.ch) reported that TeXShop jumps a page each time it typesets on Golden Gate. He also reported that he could fix this by going to line 1526 in MyPDFKitView.m and commenting out the line "visibleRet.size.height = 3;". How he found this is mysterious to me; he has debugging skills that are beyond me! Removing this line does not break any of the systems supported by Golden Gate and completely fixes the stability program, so after typesetting a user is exactly at the same spot as before.

Following these changes, TeXShop 5.57 compiles and runs on macOS Golden Gate. Apple notarized it to produce a regular program with both Intel and Arm code which runs on Sonoma, Sequoia, Tahoe, and Golden Gate. Additional Inactive Engines were added to the code, which is now called TeXShop 5.58. TeXShop 5.58 is currently based on macOS 27.3.

Running TeXShop 5.58 on macOS Golden Gate

After making these code changes, TeXShop 5.58 runs fine on Golden Gate. There are many features to check, of course, but most work as always. In macOS 27.3, there are only two known TeXShop bugs. The first is rather trivial; when a pdf document is first opened, the document is scrolled to the last page rather than opening on the first page.

The second bug is more serious. Both magnifying glasses draw nothing on the screen. The tool which selects a region by drawing a boundary around it also draws nothing. Finally, in a table of contents, the tool which briefly shows the item referenced by an item draws nothing. All of these items work the same way, by creating an invisible screen over the regular screen and drawing into that invisible screen. So there are three items, but only one bug.

However, the selection tool shows that the code almost works. If you hold down the mouse and select a region, a boundary is supposed to be drawn on the screen, but it is missing. However, if you then click inside this boundary to drag the contents, that task works just as before.

Luckily, I have both a machine running Tahoe and a second machine running Golden Gate. So I copied TeXShop 5.58 from Golden Gate to Tahoe and ran it there. To my delight, the magnifying glasses and selection tool now worked correctly! This means that the problem is not in my code and not in XCode 27.3, but solely a bug in the preview releases of Golden Gate. I've reported the bug to Apple.

Albert Guillen i Fabregas

Several weeks before the developer conference, I got an astonishing email from Albert Guillen i Fabregas (albert.guillen@eng.cam.ac.uk). Albert was a fan of dark mode, and had configured TeXShop to use Skim for previewing because that program has the amazing ability to convert preview images from black text on white to white text on black without changing the essential color of illustrations. But Albert wondered if this feature could be added directly to TeXShop. In these days when Artificial Intelligence is all the rage, he didn't just wonder but found the Skim source code and then asked Claude to produce code for the corresponding TeXShop feature. He mailed me the report from Claude, which was a TeX source file and related pdf document dated April, 2026.

This Claude report started by discussing several methods to convert images before explaining the advantages of the approach used by Skim. The report then carefully explained the basic method used by Skim, including tricky points.

This was followed with a section called "Proposed changes in TeXShop" containing actual lines of code to be added to globals.h, globals.m, FactoryDefaults.plist, MyPDFKitView.h, MyPDFKitView.m, TSTextView.m, TSPreviewWindow.h, and TSPreviewWindow.m. Many were minor additions, but MyPDFKitView.m now contained the essential code from Skim to apply a DarkMode InversionFilter covering the preview image.

The report ended with a description of areas that might need further testing, and then section noting that Skim is open source and listing the key source files describing the required filter.

Albert soon discovered that some of the code samples did not directly compile in TeXShop, so he found the required modifications and soon had the feature working. He sent me a diff file for my own attempts.

I should warn that my attempts to make this work were at first not as successful as those of Albert. The cause is explained in a later section below. Incidentally, Skim works fine on Golden Gate, even in key areas where my initial code had problems. If you are interested in the AI report from Claude, here are links to the LaTeX source it produced, and the corresponding pdf output file:

Skim, by Christiaan Hofman, Adam Maxwell, Michael McCracken

Now we come to the big guns, the guys who actually wrote the filter switching black and white in a pdf file displayed in dark mode, while simultaneously keeping the color of illustrations intact. Please do not forget the people who contributed this fantastic idea to the pdf world!

In TeXShop-5.58, we implement this technique in a very minimalist way. using the AI code which copied the filter from Skim source. When the display switches to dark mode, the Skim filter is added to the Preview Window. When the display switches back to light mode, the filter is removed. In Skim, users can choose whether to use the filter, but in TeXShop 5.58 it happens automatically.

In Skim, the dark mode filter gives the screen a rich black and white texture, while in the original version of TeXShop 5.58, the texture was gray rather than deep black. On the other hand, the magnifying glasses in TeXShop 5.58 did produce that deep black and white texture used by Skim.

To turn dark mode on and observe the new filter, use the standard Macintosh technique: open System Settings and activate the Appearance Module. Click on provided icons to select Dark mode or Light Mode.

However, there is a much easier way to make this choice. In Apple's App Store, download the free application named Nightfall. Install this program in your Applications folder. Click it to activate. The program adds a small circular icon to the system toolbar, half black and half white. Click this circle to switch from Light mode to Dark mode. Click again to switch from Dark mode to Light mode. The application thus allows you to easily switch without dealing with System Settings, and thus to quickly test the new TeXShop feature.

We have not tested the program running on Sonoma and Sequoia, the other two versions of macOS supported by programs compiled on Golden Gate.

New Development on June 25

Earlier I explained that the dark mode filter in Skim gives a rich black and white texture, while originally in TeXShop it gave a gray appearance.

Shortly after originally posting this page, I got a response from Martin Hairer. He pointed out that the Themes section of TeXShop Preferences has an option which sets the background color of the Preview Window. This can be done in both Light mode and Dark mode.

Hairer suggested that the gray appearance of the Skim filter inside TeXShop is due to this setting rather than to any code from Skim. So I commented out the line of code which can set the background color of the TeXShop Preview window. This immediately gave the rich black and white texture of Skim without changing any Skim code in TeXShop. Hairer strikes again!

Therefore TeXShop-5.58-GG available below produces the correct rich black and white texture used by Skim.

Just to be clear, the program TeXShop-5.58-GG has two current bugs on macOS 27.3, but if the program is simply copied to Tahoe, macOS 26, the bugs vanish and all of the features including the magnifying glasses and dark mode work correctly.

Downloading TeXShop 5.58 and Its Golden Gate Source Code

Below are links to version 5.58 of TeXShop, and its source code when compiled on macOS 27.3.