I created a model class that I use in my iOS application and Watch application - it is included for both purposes. Now I have to use UIPasteboard in this class, which is only available in UIKit , which is not available for watchOS. Although I can import UIKit into this file without problems, when I go to use UIPasteboard , it will not be compiled because the chat extension does not know about it.
How can I use UIPasteboard in a class available for my watch app?
I was wondering if I can run this code only when the device is not an Apple Watch using #available , but this did not solve the problem.
if #available(iOS 7.0, *) { UIPasteboard.generalPasteboard()...
source share