Post

Replies

Boosts

Views

Activity

Crash in AVCaptureDevice.requestAccess in iOS 18 with swift 6
I am facing an issue in iOS 18 that works fine in iOS 17 and earlier. This happens when you set the project to use Swift 6, if you set swift 5 this will work ok. The app has the Privacy - Camera Usage Description key in the Info.plist. It is a wrapper that implements UIViewControllerRepresentable to create the UIViewController. This wrapper is within a view that gets pushed when the user presses a button (see snippet code below). Sometimes, I get a popup asking for permission to access the camera, and the app crashes immediately. Other times, I don’t see the popup, and the app crashes right away. I tried adding Task { @MainActor } within the requestAccess closure, but it did not resolve the issue. It does not matter the code within the closure; it crashes even if the closure is empty. The crash trace shows _dispatch_assert_queue_fail (see the attached image). Has anyone else experienced this issue? Any insights would be greatly appreciated. The following code will crash if run as is. ***** Please add the Privacy - Camera Usage Description key in the Info.plist to prevent this issue. import SwiftUI import AVFoundation struct ContentView: View { var body: some View { VStack { Text("Hello, world!") ViewControllerWrapper() } } } struct ViewControllerWrapper: UIViewControllerRepresentable { func makeUIViewController(context: Context) -> ViewController { ViewController() } func updateUIViewController(_ viewController: ViewController, context: Context) {} } class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() AVCaptureDevice.requestAccess(for: .video) { _ in } } }
1
0
484
Feb ’25
How to Keep Live Activity in Expanded Dynamic Island State (ActivityKit, iOS 17+)
I'm building a Live Activity using ActivityKit in iOS, and I'm trying to understand how apps like Uber or Lyft manage to keep the Dynamic Island always in its expanded state, without transitioning through the compact phase. In my implementation, the Live Activity always starts in the compact state, and only expands temporarily when I interact with it. I've tried the following: Updating the ContentState frequently using activity.update(using:) I tried updating the activity every 1 second, but it didn’t make a difference. Leaving the compactLeading, compactTrailing, and minimal regions empty using EmptyView() — also didn’t change the behavior. Delaying the initial update by 1 second — no effect. What I'm trying to figure out: Is there any way to programmatically force or request the Dynamic Island to stay in the expanded state? Could this behavior be achieved through push updates, using apns-push-type: liveactivity and a high priority (apns-priority)? What I’m trying to achieve is similar to the behavior shown in the images below — the apps do not transition to the compact island, but instead displays the expanded view immediately. Example:
0
0
65
Apr ’25