I am currently building an iOS app with a watchOS app extension. I have certain classes that are shared between both apps, and they are largely identical on both platforms, but with certain variations. I am wondering how this is best implemented. Right now I use the following:
#if os(watchOS)
private var watchOSOnlyProperty: Any?
#endif
or
#if os(iOS)
func iOSOnlyMethod() {
...
}
#endif
While this works, it gives several problems since XCode seems to be pretty confused about this. Indentation, autocompletion and the list of methods are all a bit off when using this syntax.
What is the proper way to do this? How can you add iOS/watchOS-specific properties & methods to shared classes in Swift?