Post

Replies

Boosts

Views

Activity

Reply to how to update SwiftUI Map via MapCamera approach with data from @Observable? (see code)
Here you go // // ContentView.swift // ForumMapsQuestion // // Created by SB on 2024-01-05. // import SwiftUI import MapKit struct ContentView: View { @StateObject var locationMgr = NewLocationManager() @State private var mapCamPos: MapCameraPosition = .automatic var body: some View { ZStack { Map(position: $mapCamPos) .onReceive(locationMgr.$direction) { direction in mapCamPos = .camera(MapCamera( centerCoordinate: self.locationMgr.location.coordinate, distance: 800, heading: direction )) } .onReceive(locationMgr.$location) { location in mapCamPos = .camera(MapCamera( centerCoordinate: location.coordinate, distance: 800, heading: self.locationMgr.direction )) } VStack (alignment: .leading) { VStack { Text("Location from observable: \(locationMgr.location.description)") Text("Direction from observable: \(locationMgr.direction)") } .padding() .background(.gray) .clipShape(RoundedRectangle(cornerSize: CGSize(width: 20, height: 10))) .opacity(0.7) Spacer() } } } } #Preview { ContentView() } final class NewLocationManager: NSObject, ObservableObject, CLLocationManagerDelegate { @Published var location: CLLocation = CLLocation(coordinate: CLLocationCoordinate2D(latitude: 51.500685, longitude: -0.124570), altitude: .zero, horizontalAccuracy: .zero, verticalAccuracy: .zero, timestamp: Date.now) @Published var direction: CLLocationDirection = .zero private let locationManager = CLLocationManager() override init() { super.init() locationManager.startUpdatingLocation() locationManager.delegate = self Task { [weak self] in try? await self?.requestAuthorization() } } func requestAuthorization() async throws { if locationManager.authorizationStatus == .notDetermined { locationManager.requestWhenInUseAuthorization() } } func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { locations.forEach { [weak self] location in Task { @MainActor [weak self] in self?.location = location } } } func locationManager(_ manager: CLLocationManager, didUpdateHeading newHeading: CLHeading) { Task { @MainActor [weak self] in self?.direction = newHeading.trueHeading } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jan ’24
Reply to Can't connect to my iPhone
Yeah, Apple dropped the ball on this version of Xcode royally without publishing the changes related to the new requirements for using Xcode within corporate offsite/remote VPN scenarios and has basically pointed the finger at VPN providers when they were the ones that changed up the architecture of Xcode.
Jan ’24
Reply to how to update SwiftUI Map via MapCamera approach with data from @Observable? (see code)
Here you go // // ContentView.swift // ForumMapsQuestion // // Created by SB on 2024-01-05. // import SwiftUI import MapKit struct ContentView: View { @StateObject var locationMgr = NewLocationManager() @State private var mapCamPos: MapCameraPosition = .automatic var body: some View { ZStack { Map(position: $mapCamPos) .onReceive(locationMgr.$direction) { direction in mapCamPos = .camera(MapCamera( centerCoordinate: self.locationMgr.location.coordinate, distance: 800, heading: direction )) } .onReceive(locationMgr.$location) { location in mapCamPos = .camera(MapCamera( centerCoordinate: location.coordinate, distance: 800, heading: self.locationMgr.direction )) } VStack (alignment: .leading) { VStack { Text("Location from observable: \(locationMgr.location.description)") Text("Direction from observable: \(locationMgr.direction)") } .padding() .background(.gray) .clipShape(RoundedRectangle(cornerSize: CGSize(width: 20, height: 10))) .opacity(0.7) Spacer() } } } } #Preview { ContentView() } final class NewLocationManager: NSObject, ObservableObject, CLLocationManagerDelegate { @Published var location: CLLocation = CLLocation(coordinate: CLLocationCoordinate2D(latitude: 51.500685, longitude: -0.124570), altitude: .zero, horizontalAccuracy: .zero, verticalAccuracy: .zero, timestamp: Date.now) @Published var direction: CLLocationDirection = .zero private let locationManager = CLLocationManager() override init() { super.init() locationManager.startUpdatingLocation() locationManager.delegate = self Task { [weak self] in try? await self?.requestAuthorization() } } func requestAuthorization() async throws { if locationManager.authorizationStatus == .notDetermined { locationManager.requestWhenInUseAuthorization() } } func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { locations.forEach { [weak self] location in Task { @MainActor [weak self] in self?.location = location } } } func locationManager(_ manager: CLLocationManager, didUpdateHeading newHeading: CLHeading) { Task { @MainActor [weak self] in self?.direction = newHeading.trueHeading } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’24
Reply to Xcode debugger doesn't pause on breakpoints (simulator SDK < iOS 17)
Yup I have also noticed the same issue it’s as if the debugger is not connected to the sim.
Replies
Boosts
Views
Activity
Jan ’24
Reply to 4+ weeks of waiting for Family Controls Entitlement
Well Apple does go on a Christmas break
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Jan ’24
Reply to I want to port my metaverse app with WebRTC to visionOS but I encountered some problem.
If it doesn't compile, then it's not supported by the library. Please ask your question on the unity developers forum. Unity is not an Apple product.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Jan ’24
Reply to Error
Provide any missing images
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jan ’24
Reply to Need Help with Error message on Visual Studio Code
Visual Studio questions are best asked on the respective Microsoft forums.
Topic: Safari & Web SubTopic: General Tags:
Replies
Boosts
Views
Activity
Jan ’24
Reply to Detecting when the user lifted finger off the screen on a scrollview
onEnded of any Gesture protocol normally signifies the user has ended all interactions with the component. Don't over think it. But take a look here https://developer.apple.com/documentation/swiftui/composing-swiftui-gestures
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’24
Reply to Today Updated to Sonoma now no wifi Printer.
For the future: Please post all non-developer questions in the Apple community support forums https://discussions.apple.com/welcome.
Topic: App & System Services SubTopic: Hardware Tags:
Replies
Boosts
Views
Activity
Jan ’24
Reply to Compilation error in Apple MusicKit SDK for Android
Of course, it can be fixed by filing a bug report to Apple via the feedback app if you're on a mac or https://feedbackassistant.apple.com. When it will be fixed is another question.
Topic: Media Technologies SubTopic: General Tags:
Replies
Boosts
Views
Activity
Jan ’24
Reply to SwiftData Crashes When Using Custom Migration.
Was the original model ever created with a version number?
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jan ’24
Reply to SwiftData Crashes When Using Custom Migration.
See https://developer.apple.com/forums/thread/734479,
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jan ’24
Reply to Disabling the extra buttons on UIReferenceLibraryViewController
Overview A UIReferenceLibraryViewController object should not be used to display wordlists, create a standalone dictionary app, or republish the content in any form.
Topic: Business & Education SubTopic: General Tags:
Replies
Boosts
Views
Activity
Jan ’24
Reply to Cannot preview visionOS apps because of Packages that do not support visionOS
LightCompressor only supports iOS and tvOS. visionOS support will have to be requested from the maintainers of the project hence no symbols for visionOS unless the app is made for iPad.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’24
Reply to Firebase’s Remote Config in context of an Authorization Plugin
This is not a Google forum. Please post your question on the respective Google Firebase forum or Github repo.
Topic: Code Signing SubTopic: Entitlements Tags:
Replies
Boosts
Views
Activity
Jan ’24
Reply to Can't connect to my iPhone
Yeah, Apple dropped the ball on this version of Xcode royally without publishing the changes related to the new requirements for using Xcode within corporate offsite/remote VPN scenarios and has basically pointed the finger at VPN providers when they were the ones that changed up the architecture of Xcode.
Replies
Boosts
Views
Activity
Jan ’24