Platform specific property in Observable

With the following in an iOS and watch app

import Observation

@Observable final class DataModel {
    var common = 0
    
    #if os(iOS)
    var iProp = 0
    #endif
}

Xcode 15 beta 5 reports error: Cannot find type '_iProp' in scope

Is platform specific property forbidden in Observable objects?

You should definitely file a bug about this.

Because @Observable is a macro, it’s tricky for it to support things that should obviously Just Work™, like conditional compilation and availability. I know that we have a bug for the latter (r. 112541920) but I’m not so sure about the former, hence my request above.

Please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Platform specific property in Observable
 
 
Q