UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Day 84: HotProspects won't build on actual device

Forums > 100 Days of SwiftUI

Disclosure: I'm using XCode 13 Beta 4 and an iPhone 7 plus with iOS 15 beta 4, so this may be a new version/beta issue

I've finished the coding on HotProspects through Day 84. It works fine in the simulator, but if I switch the build target to my iPhone 7 Plus, the build will fail with the following error:

"'shared' is unavailable in application extensions for iOS: Use view controller based solutions where appropriate instead"

on line 200 of Paul's CodeScanner.swift file that was imported as a Package Dependency.

199        @objc func updateOrientation() {
200            guard let orientation = UIApplication.shared.windows.first?.windowScene?.interfaceOrientation else { return }
201            guard let connection = captureSession.connections.last, connection.isVideoOrientationSupported else { return }
202            connection.videoOrientation = AVCaptureVideoOrientation(rawValue: orientation.rawValue) ?? .portrait
203        }

Any ideas how to fix this?

UPDATE: I found Issue 37 and see that code has been changed to address this error.

guard let orientation = view.window?.windowScene?.interfaceOrientation else { return }

However, updating the Swift Package does not pull in that modification.

What do I need to do in Swift Package Manager to access this latest code update?

2      

Hacking with Swift is sponsored by RevenueCat

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.