简体   繁体   中英

macOS - Compile xib with UI elements newer than the deployment target

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 .

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.

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM