How to fix iOS 26 Beta / iOS 18 SDK compile conflicts?

A method in my app now requires the override keyword when compiling with Xcode 26 beta / iOS 26 SDK, but if I add it, the current official Xcode 16.4 (iOS 18 SDK) throws a compile error. It's about 'toggleSidebar(_:)' in UIViewController.

The problem is:

  1. Apple expects our apps to be ready for iOS 26 launch this fall, so I need to be actively developing and testing in the Xcode 26 beta now.

  2. At the same time, I still need to submit updates to the App Store using the current official Xcode 16.4 until iOS 26 officially launches.

I'm using a single .xcodeproj file and can't keep manually adding/removing -DIOS_SDK_26_OR_LATER in Build Settings multiple times a day.

How to fix it and why isn't there a straightforward #if sdk(>=26.0) type of check for compile-time in Swift? It's really frustrating to manage this override conflict.

How to fix iOS 26 Beta / iOS 18 SDK compile conflicts?
 
 
Q