Developing a multi platform app using SwiftUI. But soon ran into compile issues on macOS because of EditMode incompatibility on that platform. EditMode is quite intensively used almost in every scene in iOS and also deeply ingrained in modifier calls etc.
It is apparent the power and the potential of SwiftUI in developing complex apps and its multi platform support.
However I am a bit surprised about the cross-platform cross platform incompatibility of basic facets like EditMode. So surprised that I am questioning myself if I am doing it right. Is there a way to develop cross platform apps using SwiftUI without extensive use of preprocessor directives strewn across "shared" code?
It is apparent the power and the potential of SwiftUI in developing complex apps and its multi platform support.
However I am a bit surprised about the cross-platform cross platform incompatibility of basic facets like EditMode. So surprised that I am questioning myself if I am doing it right. Is there a way to develop cross platform apps using SwiftUI without extensive use of preprocessor directives strewn across "shared" code?
I'm a swiftUI newbie, but so far my experience has been that your cross-platform swiftUI views will be full of
And for modifiers, I guess you have to do something like this, which makes it even more annoying
Code Block #if os(...)
And for modifiers, I guess you have to do something like this, which makes it even more annoying
Code Block /// Workaround since .collapsible isn't available on iOS and there's no way to #if out the modifier function directly extension Section where Parent: View, Content: View, Footer: View { func noCollapseIOSCompat() -> some View { #if os(macOS) return self.collapsible(false) #else return self #endif } }