1

I want to use an NSGridView in a .xib file for a custom view. NSGridView's are only available on macOS 10.12 and later, but my app runs on macOS 10.11 and later.

So when compiling my application I get an error at the stage, where the .xib files are compiled:

NSGridView before OS X 10.12

What I would want to do is create two separate .xib files, one which is compatible with macOS prior to 10.12 (this would contain an alternative to NSGridView) and the other one for all above version (this would then use NSGridView). In the view controller I would load the correct .xib file based on the macOS version with if #available(OSX 10.12, *).

The problem is that the project doesn't even compile, when it contains a .xib file with an NSGridView.

Codey
  • 1,131
  • 2
  • 15
  • 34
  • Is the question how to compile the xib with the `NSGridView`, how to load a different nib at runtime on OS X 10.11 or how to build two apps (for 10.11 and 10.12+) from the same project? – Willeke Jun 24 '20 at 10:16
  • Use two different xib files depending on the OS version to back the same view controller? – El Tomato Jun 24 '20 at 10:20
  • @Willeke Since loading the nibs happens in code I can use `if #available(OSX 10.12, *)`. The problem is the compilation, as it already fails when I just want to build the app (and the xib) without loading it – Codey Jun 24 '20 at 10:44
  • @ElTomato Yes that's exactly what I want to do, but the app doesn't even compile when the project contains a xib file, with `NSGridView` – Codey Jun 24 '20 at 10:45
  • I see. You are right. – El Tomato Jun 24 '20 at 10:55
  • Your best bet is to post a question at Apple's developer forums. There are very knowledgeable people like Eskimo there. Or you may also consider opening a technical support ticket with TSI. – El Tomato Jun 24 '20 at 11:14

1 Answers1

2

You can select the GridView in your .xib and in File Inspector you can choice the appropriate version this grid view should be built under "Builds for" dropdown. Works for me, no compilation error.

enter image description here

Nandish
  • 1,136
  • 9
  • 16