I have created a model class that I use in my iOS app and my Watch app - it is included in both targets. Now I have to use UIPasteboard
in this class which is only available in UIKit
, which is not available to watchOS. While I can import UIKit into this file without issue, when I go to use UIPasteboard
it will not compile because the watch extension does not know about it.
How can I use UIPasteboard
in a class that is available to my watch app?
I wondered if I could only run that code when the device isn't an Apple Watch by using #available
, but this didn't resolve the issue.
if #available(iOS 7.0, *) {
UIPasteboard.generalPasteboard()...
//ERROR: Use of unresolved identifier 'UIPasteboard'
} else {
//don't use UIPasteboard
}