Post

Replies

Boosts

Views

Activity

Back supported Navigation-View
Is there any convenient way to back deploy the NavigationStack or NavigationSplitView?? The real problem is if I want to back support iOS 15 or 14, I must conditionally switch between NavigationView and NavigationStack / NavigationSplitView. Here is how I did for NavigationStack, but I have no idea how to deal with NavigationSplitView import SwiftUI struct NavigationStack<Content: View>: View {     var content: () -> Content     var body: some View {         if #available(iOS 16.0, macOS 13.0, *) {             SwiftUI.NavigationStack {                 content()             }         } else {             NavigationView {                 content()             }.navigationViewStyle(.stack)         }     } } Will the new NavigationStack and NavigationSplitView back support old devices? I think these behaviors in previous OS is not new features.
1
0
1.6k
Jul ’22
App Terminates when using Window and MenuBarExtra in SwiftUI
If you configure a Window and a MenuBarExtra in your app, try this: Open your app and press Command+H to hide it. Place an iPad or another Mac and connect two devices via Universal Control, and click on the other device to make your mac's menu bar inactive. Move your cursor back to your Mac(first device), and click on the whitespace of the Menu Bar. Your App is terminated unexpectedly. This behavior will only appear on those apps using Window, so to solve this issue, we may need to switch Window to WindowGroup which is not what we want. I reappear this issue on Apple's ScreenCaptureKit Sample Code. This is a SwiftUI Scene BUG, please fix this. @main struct CaptureSampleApp: App { var body: some Scene { Window("ID", id: "ID") { ContentView() .frame(minWidth: 960, minHeight: 724) .background(.black) } MenuBarExtra( "App Menu Bar Extra", systemImage: "star" ) { Text("Hello") } } } Filed a feedback: FB11447959.
0
0
1.3k
Sep ’22
isReadyForMoreMediaData and AVAssetWriterInput
I created a screen recording app. Before appending the buffer to the writer, I check if the isReadyForMoreMediaData is true. But sometimes it will constantly return false and won’t become true until I call markAsFinished I have no idea how to fix this. let videoCompressionProperties = [     AVVideoAverageBitRateKey: resolution.dataRate ] let videoSettings: [String: Any] = [     AVVideoCodecKey:                  encoding,     AVVideoWidthKey:                  resolution.size.width,     AVVideoHeightKey:                 resolution.size.height,     AVVideoCompressionPropertiesKey:  videoCompressionProperties,     AVVideoScalingModeKey:            AVVideoScalingModeResizeAspect,     AVVideoColorPropertiesKey:        colorSpace.properties.dictionary, ] videoInput = AVAssetWriterInput(mediaType: .video, outputSettings: videoSettings) videoInput?.expectsMediaDataInRealTime = true Append buffers: if videoInput?.isReadyForMoreMediaData == true { guard buffer.imageBuffer != nil else { return } processQueue.async { [self] in videoInput?.append(buffer) } } else { logger.warning("Dropped a frame.") // I found this in stackoverflow. But no effect // RunLoop.current.run(until: .now.addingTimeInterval(0.1)) // The code below will notify me when the bug occurrs. // errorFixedPublisher.send() // if !self.errorOccured { // self.errorOccured = true // let center = UNUserNotificationCenter.current() // let content = UNMutableNotificationContent() // content.sound = UNNotificationSound.defaultCritical // content.badge = 1 // content.body = "Dropping frames at \(Date.now.formatted(date: .omitted, time: .standard))" // let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 1, repeats: false) // let req = UNNotificationRequest(identifier: "ASWRI_ERR", content: content, trigger: trigger) // center.add(req) } } Any idea on it?? Please help me. Have a good day!
1
0
1.3k
Oct ’22
How to sync video and audio?
Background I use AVAssetWriterInput.append to append sample buffer to the writer. Sometimes, I switch off the audio input(if user wants to temporarily disable audio input), so the append method will not be executed while the append method in video input will always be executed. Problem If user pause the audio and resume it later. The audio after resuming will immediately begin when user pause it (in the final video). Example '=' refers to CMSampleBuffer. '|' means user paused the audio input. Video: ---------------================================= Audio(expected): ----=======|----------------============= Audio(I got): ---------=======|=============---------------- I have printed the presentationTime from the audio sample buffer, it turns out it's correct. Maybe my understanding to the AVAssetWriterInput.append is wrong? My current solution is to always append the buffer, but when user wants to pause, I simply append an empty SampleBuffer filled with nothing. I don't think this is the best way to deal with it. Is there any idea to sync the buffer time with the video??
1
0
1.2k
Nov ’22
Cannot see my widget in Widget Gallery (macOS)
I used a package which contains a XCFramework inside it in my widget target. It’s working fine on iOS, and macOS Widget Simulator. But when I open widget gallery on macOS, I can’t find my widget. I tried to run my widget directly inside /Contents/PlugIns/WidgetTestExtension.appex/Contents/MacOS/WidgetTestExtension, it prints out the error: dyld[4767]: Library not loaded: @rpath/myframework.framework/Versions/A/myframework
0
0
553
Aug ’23