statsig-io / ios-sdk

Statsig's SDK for client-side iOS applications.
ISC License
15 stars 8 forks source link

visionOS support #12

Closed aaron-foreflight closed 7 months ago

aaron-foreflight commented 7 months ago

We would like to have visionOS support as our app is visionOS only.

I looked at PlatformCompatibility.swift and since visionOS can import UIKit, but does not have the keyWindow API, I think the primary change there should look something like this:

#if os(iOS)
    if let klass = UIApplication.shared.keyWindow?.rootViewController?.classForCoder {
        callback("\(klass)")
    } else {
        callback(nil)
    }
#endif

#if os(visionOS)
    if let scene = UIApplication.shared.connectedScenes.filter({ $0.activationState == .foregroundActive }).first as? UIWindowScene,
       let windowSceneDelegate = scene.delegate as? UIWindowSceneDelegate,
       let klass = windowSceneDelegate.window??.rootViewController?.classForCoder {
        callback("\(klass)")
    } else {
        callback(nil)
    }
#endif```
tore-statsig commented 7 months ago

Thanks for the report. We talked about it when vision pro came out, but I didnt expect a feature request for support so quickly. We will look into it

daniel-statsig commented 7 months ago

visionOS is now supported: https://github.com/statsig-io/ios-sdk/releases/tag/1.39.0