1

I've designed an app that includes support for the touch bar. The touch bar is created in Interface Builder. All code uses Swift's #available checks to make sure that no touch bar code gets executed on macOS prior to 10.12. The XIB (and app) is set to deploy to 10.10, but when I run my app I still get errors like:

-[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (NSTouchBar)

How can I make sure that decoding the XIB skips the touch bar on macOS prior to 10.12?

Remco Poelstra
  • 859
  • 6
  • 20

1 Answers1

0

You have two choices.

  1. Create the UI programmatically.

  2. Register dummy class pairs for the class name. I'm not sure how to achieve this in Swift, but there is an Obj-C solution here: How to use NSVisualEffectView backwards-compatible with OSX < 10.10?. That answer also provides some extra caution regarding subsequent access of the component.

Community
  • 1
  • 1
Oskar
  • 3,625
  • 2
  • 29
  • 37