Post

Replies

Boosts

Views

Activity

Reply to ApplicationMusicPlayer.shared.state.playbackStatus unexpected results
Since you've solicited info: I just encountered a problem with MusicPlayer.State, in that it doesn't work with the current Observation framework. For example, this does not work: withObservationTracking { _ = musicPlayer.state.playbackStatus } onChange: { Task { print("PlaybackManager observed player-state change, to \(await self.musicPlayer.state).") await self.playerChanged() await self.startObserving() // await because of MainActor } } I had migrated my application's observation usage to the new world order, but it looks like I have to revert files that use MusicPlayer. Also: I urge the frameworks developers to abandon the idea that people are just slapping stuff into a SwiftUI view and calling it a day. This has turned development on Apple platforms into a tedious slog of workarounds and tricks to let controller-type objects communicate with each other; and repeated disappointment when each new observation regime repeats the same mistakes (for example, only offering "willChange" and not "didChange").
3w
Reply to How do you allow arbitrary file selection in your own app?
Thanks! That does work, with the slight addition of having to call that method on the URL returned by the file dialog. So my button to open a file in SwiftUI looks like: Button(action: { isImporting = true }, label: { Text("Open P8 file") }) .fileImporter(isPresented: $isImporting, allowedContentTypes: [.data], onCompletion: { result in switch result { case .success(let theURL): do { let didStart = theURL.startAccessingSecurityScopedResource() defer { if didStart { theURL.stopAccessingSecurityScopedResource() } } secretKey = try String(contentsOf: theURL, encoding: .utf8) generateToken() } catch { message = error.localizedDescription } case .failure(let error): print(error) } }) I filed a bug report on the documentation.
4w
Reply to App will build and run once; then crashes on phantom AVPlayerView reference every time
For anyone else with a similar problem: This is apparently a known issue, although presumably the exact error message may differ. As a workaround, you can turn off view debugging. Thanks to Apple for providing this information while they investigate: Select your target and click on "Edit Scheme...". Then, under Run (Debug) > Options > View Debugging, uncheck the "Enable user interface debugging" box.
Oct ’24