3

So I'm trying to compile my iOS project for the mac, and when I try to use

#if !targetEnvironment(UIKitForMac)

I'm getting the error from the title.

I tried setting the build target to iOS 13, but didn't seem to have any effect.

Jan
  • 2,462
  • 3
  • 31
  • 56

2 Answers2

2

Objective-C

#if !TARGET_OS_MACCATALYST
// Code to exclude from Mac.
#endif

Swift

#if !targetEnvironment(macCatalyst)
// Code to exclude from Mac.
#endif

Sources:

Alex Walczak
  • 1,276
  • 1
  • 12
  • 27
0

If you're using objective-c and not swift you should use:

#if !TARGET_OS_UIKITFORMAC
#endif
D. Mika
  • 2,577
  • 1
  • 13
  • 29
  • That was it! Is this documented anywhere? Even when selecting Objective-C in the official docs don't show this: https://developer.apple.com/documentation/uikit/creating_a_mac_version_of_your_ipad_app?language=objc – Jan Jun 10 '19 at 14:56
  • It think this is a documentation bug because it shows the same code regardless the selected language. It was shown in the WWDC talk, and code completion helps as well. :-) – D. Mika Jun 10 '19 at 15:03
  • Code completion is not doing anything for me :( Might be because my computer is super slow with Xcode 11. Anyway, thanks! – Jan Jun 10 '19 at 15:14