Wednesday, November 30, 2022
HomeiOS Developmentios - Conditionally embody macOS-only code in a SwiftUI (Mac Catalyst) venture?

ios – Conditionally embody macOS-only code in a SwiftUI (Mac Catalyst) venture?


I’m writing an app that runs on each iOS and macOS, utilizing Mac Catalyst with Swift.

I need to set a property that’s solely obtainable on macOS however I can not discover a method utilizing #obtainable or @obtainable to forestall the compiler from together with this line of code within the iOS builds:

This syntax doesn’t work as a result of the necessary trailing * consists of all iOS variations.

if #obtainable(macCatalyst 13.0, *) {
    view.showsZoomControls = true
}

I attempted including a nonsense model of iOS utilizing iOS 999 however that did not work both, as a result of the property is marked strictly unavailable in iOS.

Utilizing @obtainable there is a longhand syntax utilizing launched: that enables per-OS variations to be specified and requires a separate @obtainable entry per OS however I am unable to see any method to make use of that. It appears you possibly can’t use @obtainable on a block of code.

Is there actually no sane method to do that?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments