Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
所以我试图为mac编译我的iOS项目,当我尝试使用
#if !targetEnvironment(UIKitForMac)
我从标题中得到错误。
我尝试将构建目标设置为 iOS 13,但似乎没有任何效果。
Objective-C
#if !TARGET_OS_MACCATALYST // Code to exclude from Mac. #endif
迅速
#if !targetEnvironment(macCatalyst) // Code to exclude from Mac. #endif
资料来源:
https://developer.apple.com/documentation/uikit/creating_a_mac_version_of_your_ipad_app?language=objc
https://developer.apple.com/documentation/xcode/creating_a_mac_version_of_your_ipad_app
如果您使用的是objective-c而不是swift,您应该使用:
#if !TARGET_OS_UIKITFORMAC #endif