Jan
Jan

Reputation: 2522

"Token is not a valid binary operator in a preprocessor subexpression" when using UIKitForMac

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.

Upvotes: 3

Views: 1453

Answers (2)

Alex Walczak
Alex Walczak

Reputation: 1396

Objective-C

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

Swift

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

Sources:

Upvotes: 2

D. Mika
D. Mika

Reputation: 2808

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

#if !TARGET_OS_UIKITFORMAC
#endif

Upvotes: 0

Related Questions