Xcode 12 error: iOS xibs do not support target device type "mac"

I have a Swift package that supports multiple platforms:

We are in the process of adding some UIViews with their corresponding .xib files. These UIView classes are wrapped inside #if canImport(UIKit) so they are only available on those platforms.

SwiftPM seems to build fine from the command line with swift build. We can also run tests with swift test. Furthermore, we can run tests for iOS with:
xcodebuild test -scheme 'Foo-Package' -destination 'OS=14.0,name=iPhone 8'

However, we trying to build or run tests in Xcode 12, with 'My Mac' as the selected destination, we get the following error:

Showing All Errors Only
CompileXIB /path/to/some.xib (in target 'Foo_Bar' from project 'Foo')

/* com.apple.ibtool.errors */
/path/to/some.xib: error: iOS xibs do not support target device type "mac".

Is there a way to specify, in Swift Package Manager, that resources are for a specific platform only? We have no interest on using that resource in other platforms than iOS.


1 Like

Did anyone found a workaround? Why apple not fixing this?