简体   繁体   中英

How to differentiate between iphone/ipad and macOS/BigSur on an iOS only project?

If you want to build only an iOS app but want it to be able to run on BigSur as well you only need to open a project for iOS only and then can add Mac as deployment in the App settings Deployment Info. This will run on the mac then as well using the iOS app.

But using

#if os(iOS)
#else
#endif

will not work here because you are only running an iOS app in the first place!

My Question:

How do you differentiate between the two cases of an iOS app on an iPhone/iPad and an iOS app on MacOS?

#if targetEnvironment(macCatalyst)
#else
#endif

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