Post

Replies

Boosts

Views

Activity

SwiftUI crash deleting List element / conditional rendering
Using Xcode 11 beta 7, I'm getting an unexpected EXC_BAD_INSTRUCTION crash with this very simple view. It manages a list where you can add and delete items. The list starts off empty, and the crash occurs after you add any items and delete them so that the list is empty again.The conditional rendering of something different when the list is empty (if items.count == 0...) seems to have something to do, because if I unconditionally render a List there is no crash. Yet I see no issue with the code as it is. Note that right before crashing, Text("empty") is correctly rendered.Any ideas...?struct TestView: View { @State var items: [Int] = [] var body: some View { VStack { Button(action: { self.add() }) { Text("Add") } if items.count == 0 { Text("empty") } else { List { ForEach(items, id: \.self) { item in Text("item #\(item)") } .onDelete(perform: { self.delete(offset: $0.first! )}) } } } } func delete(offset: Int) { DispatchQueue.main.async { self.items.remove(at: offset) } } func add() { DispatchQueue.main.async { self.items.append(self.items.count) } } }
1
0
1.8k
Sep ’19
modifyRecordsCompletionBlock deprecated on iOS 15
I want to target iOS 15 and I get deprecation warnings in some CloudKit properties. I was using modifyRecordsCompletionBlock on CKModifyRecordsOperation and now I get: 'modifyRecordsCompletionBlock' was deprecated in iOS 15.0: Use modifyRecordsResultBlock instead However with modifyRecordsCompletionBlock I'd get an array of the successfully modified records as input for the block which I'd in turn use for updating my local DB, whereas the input for modifyRecordsResultBlock is Result<Void, Error>. Basically I'm being told to use a different closure where I get no data and I don't know how to complete my local DB updates. Any ideas?
3
1
2k
Dec ’21
confirmationDialog not working in child view controller
So actionSheet is deprecated in favor of confirmationDialog. When trying to migrate I'm noticing that the latter doesn't work when the view is in a child view controller! I have created a simple project to demonstrate the issue. https://github.com/gbuela/cddemo I have a SheetView and a DialogView, they display a button to try either API. In the ViewController, these are loaded into UIHostingController's and added as children into two UIView's. Only SheetView works. I added a Pop Up button to alternatively load DialogView in a pop up, in this context it is not a child view controller and it works. Is this simply a SwiftUI bug or do I need to do something else to make it work?
2
0
1.4k
Mar ’22
Weird error trying to add Apple Music item to library on iPadOS 16.1
I don't know if this is related to the OS version (iPadOS 16.1) but this used to work for me before on this particular device. I'm doing this: try await MPMediaLibrary.default().addItem(withProductID: catalogId) where catalogId is a valid ID I got from MusicKit. This throws the following error: Error Domain=MPErrorDomain Code=0 "An unknown error occurred." UserInfo={NSLocalizedDescription=An unknown error occurred., NSUnderlyingError=0x2814a1b60 {Error Domain=ICCloudClientErrorDomain Code=2003 "Attempting to retrieve handler for an unsupported configuration" UserInfo={NSLocalizedFailureReason=An ICCloudClient (or HSCloudClient) instance is using a signed-out user identity., NSLocalizedRecoverySuggestion=Listen to ICActiveUserIdentityDidChangeNotification and either update ICCloudClient with the new active account or recreate it, NSLocalizedDescription=Attempting to retrieve handler for an unsupported configuration}}} Not a single Google result for that. The same code on an iPhone with iOS 16.0 works just fine. I tried observing for Notification.Name("ICActiveUserIdentityDidChangeNotification") but that doesn't seem to be fired.
2
0
2k
Sep ’22
Task not executing at all
I have an 8th generation iPad, now updated with iPadOS 16.2 (20C65) and I have an issue that I also saw on earlier 16.* betas. Task is not executing at all. This is so frustrating because I have adopted async/await in my app, I support iOS 15+, everything was working fine but now that stuff inside Task { } is not executed my app seems to be broken. (Note: my main device is an iPhone 11, still on iOS 16.0, and it works fine there.) It is also frustrating to see no other developers are complaining about this, like it happens only with my app. I have debugged with print statements and breakpoints and I can say for sure that stuff is not executing. Does anybody have any ideas? Anything else I can try? FB11866066
17
0
3.6k
Dec ’22
MPMediaQuery not returning updated results
I have noticed changes Apple Music made to my library, take in particular a changed album edition that is reflected in how the title is listed. I can see the new title in the Music app in two different devices. On one device MPMediaQuery returns the album with the new title. The other device (an iPad with less memory, in case that matters) is still returning the old edition. Is there anything I can do to make sure the data returned is up to date and matches what is seen in the Music app?
0
0
740
Jul ’23
How to use String Catalogs using a fallback language?
I have English as the base language but I also support English (UK) which defines a few UK specific localizations but should fall back to English for everything else. The way I have it now, all my fallback strings are in "New" state in the UK localization, ie they don't have a UK specific string. This actually works, but UK completion is at 5% and I can't find a way to tell it that the rest are OK to be taken from the base language. By keeping a lot of "New" strings, the tool won't be helping me when I add more strings to the base language. Marking those as Reviewed creates a blank string localization which is obviously not what I need. BTW if marking as reviewed would help here, it would be a pain because it has to be done one by one, I can't multi select.
0
0
866
Aug ’23
Infinite loop getting "_dismiss changed"
I'm working on a NavigationStack based app. Somewhere I'm using: @Environment(\.dismiss) private var dismiss and when trying to navigate to that view it gets stuck. I used Self._printChanges() and discovered the environment variable dismiss is changing repeatedly. Obviously I am not changing that variable explicitly. I wasn't able to reproduce this in a small project so far, but does anybody have any idea what kind of thing I could be doing that might be causing this issue? iOS 17.0.3
7
3
1.4k
Oct ’23
Cannot read playbackStoreID property from MPMediaItem in Mac target
Running in a Mac (Catalyst) target or Apple Silicon (designed for iPad). Just accessing the playbackStoreID from the MPMediaItem shows this error in the console: -[ITMediaItem valueForMPMediaEntityProperty:]: Unhandled MPMediaEntityProperty subscriptionStoreItemAdamID. The value returned is always “”. This works as expected on iOS and iPadOS, returning a valid playbackStoreID. import SwiftUI import MediaPlayer @main struct PSIDDemoApp: App { var body: some Scene { WindowGroup { Text("playbackStoreID demo") .task { let authResult = await MPMediaLibrary.requestAuthorization() if authResult == .authorized { if let item = MPMediaQuery.songs().items?.first { let persistentID = item.persistentID let playbackStoreID = item.playbackStoreID // <--- Here print("Item \(persistentID), \(playbackStoreID)") } } } } } } Xcode 15.1, also tested with Xcode 15.3 beta 2. MacOS Sonoma 14.3.1 FB13607631
1
1
879
Feb ’24
MusicLibraryRequest: can't query track by title?
I'm trying to find a library item by title and artist but it returns 0 items. Example below for existing track in my library. With title filter commented out, it successfully gives me all library items for that artistName. If I add the title filter, or have only the title filter, I get 0 items. Why is that? var request = MusicLibraryRequest<MusicKit.Track>() // request.filter(matching: \.title, equalTo: "Crises (Remastered 2013)") request.filter(matching: \.artistName, equalTo: "Mike Oldfield") let response = try await request.response() I can find the track by filtering the returned tracks by artist, but I feel this might not be an ideal approach if I have a bunch of tracks to find, possibly by different artists. The reason I'm not querying by id is that I'm planning to do this sort of query for non Apple Music items and if I'm not mistaken there is no cross-device id for those (even with Sync Library on). If I have the app on multiple devices with the same Apple ID looking at the same library, I want device 2 to find the track you interacted with on device 1. If there are better ways to solve this, any ideas are welcome. Appreciate any help.
1
0
594
Mar ’24
MusicLibraryRequest on macOS doesn't return non-Apple Music tracks
I filed FB13689023 for this since it is clearly unexpected. Non Apple Music library tracks are not returned on macOS using MusicLibraryRequest. I tried querying by artist where I only get Apple Music tracks, and by id where I don't get the track. On iPhone and iPad I was able to get both AM and non-AM tracks, that's how I got a valid id to try on macOS. Sync Library is on. The build targets My Mac (Designed for iPad). I'm using Xcode 15.3 and I'm on Sonoma (14.4). Any help is appreciated...
1
0
694
Mar ’24
Album art in App Store screenshots of music apps
Album art in App Store screenshots of music apps: OK or not? The only reason I ask is that I see several apps in the store that feature album artwork by artists like Taylor Swift, The Beatles, Radiohead and so on. Across the internet everyone says this it's a no-no if you don't own the copyright of the images. I get that but what's the deal with all these apps? Are these devs simply taking chances each time they submit for review?
0
0
329
May ’24