How do I update macOS App Store apps to the latest compatible version? I have rather belatedly (March 2021) updated my macBook to Mojave.  Because I depend on Aperture and other 32-bit apps I can't update to Catalina.
brew doctor tells me:
Warning: Your Xcode (10.1) is too outdated.
Please update to Xcode 11.3.1 (or delete it).
Xcode can be updated from the App Store.

But unfortunately trying to update Xcode or other out-of-date apps, including iMovie, using the App store:

The Updates tab (⌘7) says &quot;No Updates.  All your apps are up to date&quot;.
When I go to page for Xcode and click &quot;update&quot;, it tells me &quot;We could not complete your update.  Xcode can’t be installed on “Macintosh HD” because macOS version 10.15.4 or later is required.&quot;  I get similar messages for iMovie.
The profile tab (⌘0) shows both Xcode and iMovie in the list of purchases, but the buttons next to each just say &quot;Open&quot;.

Sometimes, if I wait a while, the button next to Xcode (but not iMovie) will change to say &quot;update&quot;, and when I click on it I get a dialog that says &quot;Download an older version of Xcode?  The current version requires OS X 10.15.4 or later, but you can download the last compatible version&quot;—but when I click &quot;Download&quot; the same dialog reappears again immediately.





How can I install the latest compatible version of apps originally installed through the App Store on older versions of macOS?
Xcode can be updated by downloading the appropriate release from the Additional Downloads section of https://developer.apple.com/ - for Mojave, the latest compatible version is 10.3.1, or consult this Xcode compatibility table for other macOS versions (as suggested by aMike—thanks!)
It can be installed simply by uncompressing the downloaded .xip file and then dragging Xcode.app to /Applications/.