#available issue on visionOS

Hi, do you guys have any idea why this code block doesn't run properly on a designed iPad app running on a vision pro simulator?

I'm trying to add a hovering effect to a view in UIKit but it just doesn't enter this if statement.

if #available(iOS 17.0, visionOS 1.0, *) {
    someView.hoverStyle = .init(effect: .automatic)
}

Hello @MarcoLopes,

Are you sure that branch does not execute? Is it possible there is something else in your app preventing that path of execution from being taken?

The following example works for me:

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
        
        if #available(iOS 17.0, visionOS 1.0, *) {
            
            let button = UIButton(type: .system)
            button.translatesAutoresizingMaskIntoConstraints = false
            view.addSubview(button)
            
            NSLayoutConstraint.activate([
                button.centerXAnchor.constraint(equalTo: view.centerXAnchor),
                button.centerYAnchor.constraint(equalTo: view.centerYAnchor)
            ])
            
            button.setTitle("Hello", for: .normal)
            
            button.hoverStyle = .init(effect: .automatic)
        }
    }
}

Hi @gchiste

Yes I'm sure, I'm running a iPad-compatible app on the Vision Pro simulator, I don't know if that matters. And in that case if it will be considering running iOS (because of the iPad version) or visionOS.

Thanks

I just updated to the latest xcode and now I'm running on visionOS 1.1 and the issue is solved.

#available issue on visionOS
 
 
Q