Post

Replies

Boosts

Views

Activity

WebPage doesn't seem to update view when changed in SwiftUi
I tried the new WebView api in swiftui and tried to pass webPage for this view to be able to control the navigation of the user by giving him the option to go back or forward using nav buttons but the view doesn't get's updated when the webPage.backForwardList.backList so the buttons remains disabled. code snippet: @available(iOS 26, *) struct LinkWebViewFor26: View { let url: URL @State var webPage = WebPage() @Environment(\.dismiss) private var dismiss var body: some View { WebView(webPage) .webViewBackForwardNavigationGestures(.disabled) .task { webPage.load(url) } .toolbar { ToolbarItem(placement: .topBarTrailing) { Button { dismiss() } label: { Image(systemName: "checkmark") } .buttonStyle(.glassProminent) } ToolbarItemGroup(placement: .topBarLeading) { BackForwardMenu( list: webPage.backForwardList.backList, label: .init(text: "Backward", systemImage: "chevron.backward") ) { item in webPage.load(item) } BackForwardMenu( list: webPage.backForwardList.forwardList.reversed(), label: .init(text: "Forward", systemImage: "chevron.forward") ) { item in webPage.load(item) } } } .onChange(of: webPage.backForwardList) { _, _ in print(webPage.backForwardList.backList) } } }
1
0
128
Sep ’25
AVAssetExportSession failed to export audio
I am trying to use AVAssetExportSession to export audio form video but every time I try it, it fails and I don't know why ?! this is the code import AVFoundation protocol AudioExtractionProtocol { func extractAudio(from fileUrl: URL, to outputUrl: URL) } final class AudioExtraction { private var avAsset: AVAsset? private var avAssetExportSession: AVAssetExportSession? init() {} } //MARK: - AudioExtraction conforms to AudioExtractionProtocol extension AudioExtraction: AudioExtractionProtocol { func extractAudio(from fileUrl: URL, to outputUrl: URL) { createAVAsset(for: fileUrl) createAVAssetExportSession(for: outputUrl) exportAudio() } } //MARK: - Private Methods extension AudioExtraction { private func createAVAsset(for fileUrl: URL) { avAsset = AVAsset(url: fileUrl) } private func createAVAssetExportSession(for outputUrl: URL) { guard let avAsset else { return } avAssetExportSession = AVAssetExportSession(asset: avAsset, presetName: AVAssetExportPresetAppleM4A) avAssetExportSession?.outputURL = outputUrl } private func exportAudio() { guard let avAssetExportSession else { return } print("I am here \n") avAssetExportSession.exportAsynchronously { if avAssetExportSession.status == .failed { print("\(avAssetExportSession.status)\n") } } } } func test_AudioExtraction_extractAudioAndWriteItToFile() { let videoUrl = URL(string: "https://storage.googleapis.com/gtv-videos-bucket/sample/ForBiggerMeltdowns.mp4")! let audioExtraction: AudioExtractionProtocol = AudioExtraction() audioExtraction.extractAudio(from: videoUrl, to: FileMangerTest.audioFile) FileMangerTest.tearDown() } class FileMangerTest { private static let fileManger = FileManager.default private static var directoryUrl: URL { fileManger.urls(for: .cachesDirectory, in: .userDomainMask).first! } static var audioFile: URL { directoryUrl.appendingPathComponent("audio", conformingTo: .mpeg4Audio) } static func tearDown() { try? fileManger.removeItem(at: audioFile) } static func contant(at url: URL) -> Data? { return fileManger.contents(atPath: url.absoluteString) } }
0
0
548
Jul ’24
How to make my iPhone app view on an iPad
my app was rejected by this reason: While we appreciate that your app is intended primarily for use on iPhone, in order to bring your app into compliance with App Store guidelines, all apps designed for use on iPhone must still be formatted correctly and behave properly when run on iPad. How can I solve this problem without adding iPad as a destination in Xcode.
2
0
750
Aug ’23