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. This version automatically adds the latest version of Liquid Glass to the program.

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.

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. But then, I discovered that the two magnifying glasses and the tool to select a region and copy its contents to somewhere else all fail. These three tools all work in the same way, by creating an invisible screen over the regular screen and drawing into this invisible screen.

However, the selection tool shows that the code almost works. If you hold down the mouse and select a region, a dotted 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.0, but solely a bug in the first preview release of Golden Gate. I've reported the bug to Apple.

Yesterday, one week after the start of the developer conference, Apple released a new version of Golden Gate to developers and I immediately installed it. The magnifying bug had not been fixed, but that was too soon for Apple to look at it. However, there was one dramatic change to PDFKit which affected the TeXShop Preview Window. If the contents of this view are scrolled up, they do not vanish when reaching the toolbar; instead they now scroll under that toolbar and continue up to the very top of the page. At first this is just surprising, but as we all see, in some cases it is annoying. My hope is that this is an option which developers can control.

So again I moved TeXShop 5.58, newly compiled for this version of Golden Gate, to Tahoe. The contents do not scroll under the toolbar on Tahoe, so all is well there.

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 have not been as successful as those of Albert. Incidentally, Skim works fine on Golden Gate, even in key areas where my current code has major 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 Mc Cracken

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 current TeXShop 5.58, the texture is gray rather than deep black. On the other hand, the magnifying glasses in TeXShop 5.58 do produce that deep black and white texture used by Skim. We are trying to solve this problem and always use the Skim coloring, but even if we fail, the current coloring in TeXShop is a definite improvement.

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 end with a piece of bad news, followed by a piece of good news. In the latest version of Golden Gate provided to developers, the contents of the Preview Window can be scrolled under the Preview toolbar and right to the top of the screen. However, the Skim filter is only applied to the original screen size, so the new portion under the toolbar has standard Light colors rather than Black colors. That is the bad news. We hope this is fixed in later Golden Gate developer releases.

But if TeXShop 5.58 is copied to Tahoe and the preview contents are pushed up, they vanish at the top of the active portion and do no scroll under the toolbar. So the problem goes away and the new TeXShop feature (that is, Skim feature) works fine.

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 in TeXShop it gives a gray appearance. I added that we are trying to fix this problem, but even without a fix the filter in TeXShop is an improvement.

Shortly after 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!

The previous problem is fixed in the copy of TeXShop-5.58-GG available below, and in the associated TeXShop source code.

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.0.