BaronSharktooth100 Days 💪•

49 blocks of code that are behind the #if os(macOS) compiler directive, and 55 that are behind #if os(iOS).

Oof.

Instead of trying to shoehorn as much of the iOS layouts into the macOS app as I could, I started to modularise Views into the smallest units that would work on both platforms.

Very nice.

I gotta sat, this is a very interesting article. Skips the technical details, and I was able to read about the experience in 5 minutes.

5
frowatOP•

Thanks! This is exactly what I was going for. I don’t think I’d add much by including random code examples, but wanted to give a high-level perspective on the process.

The #ifdefs aren’t actually as clunky as it that makes it seem. Most cases are just because the same view might have to be presented as a sheet on one platform vs as a tab on the other. Or for the odd property that isn’t available on one platform.

3
thekavisha•

Thank you for sharing and congratulations on your app!

I also recently released a SwiftUI app, but could not get around writing the if-else part to support the Mac version. I started with it but somehow felt the code got clunky. Reading your post is making me want to go back and finish the Mac version too. 😬

3
frowatOP•

I'm glad to hear that! I felt the same way the first time around for sure, but it got a lot more manageable as I got more familiar with SwiftUI overall.

1
Iankoex•

I am making an app and was on the fence on making Mac version. Everytime I wrote something for iOS and it works, trying on the MacOS I would get errors. I guess I'll go and work on it.

2
[deleted]•

[deleted]

1