Post

Replies

Boosts

Views

Activity

Reply to SwiftUI apps on macOS don't relaunch after being minimized
I've found a hack since AppDelegate.applicationShouldHandleReopen(_:hasVisibleWindows:) is not called as explained in the comment above. Apparently AppDelegate.applicationWillBecomeActive(_:) is called when you click on the Dock app icon if the window is miniaturized, so inside that method simply add this and seems to be working as expected (macOS 12.4): func applicationWillBecomeActive(_ notification: Notification) {     (notification.object as? NSApplication)?.windows.first?.makeKeyAndOrderFront(self) }
May ’22
Reply to SwiftUI apps on macOS don't relaunch after being minimized
I've been digging how to implement this manually and seems that AppDelegate.applicationShouldHandleReopen(_:hasVisibleWindows:) would've done the trick, but even if you implement the @NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate, that method is never called. Found another example of the same issue online: https://www.reddit.com/r/SwiftUI/comments/u5srtt/applicationshouldhandlereopen_is_not_called_in
May ’22
Reply to Why does CloudKit data field (bytes) take up more (~10 times) iCloud storage than asset field?
I've been digging deeper on this issue because it's affecting my app, and the problem is clearly and issue calculating the size on iCloud. The information that I'm adding now it's already on the FB9770168, but I'm posting it anyway here so non-Apple employees can see the findings. Size reported on my app's settings by calling allThumbnailsSize() shown above. Size reported for iCloud Storage Size reported by iPhone Storage (from the 216.6 MB, you'd have to subtract ~100MB from another database that I have on the app.) iCloud size reported for the same app on my Mac: As you can see, even if the 216.6 MB were true (which they are not, explained above), the iCloud size it totally wrong. I even went a step further and decided to perform a test to see how much data was being downloaded from iCloud. What I did is delete the app from my device, reset the network statistics, let it download all the information from iCloud, and check the statistics again. As shown on the images, if the iCloud size was correct, the download of all my data should have consumed ~757.1 MB. What it actually consumed is just ~78 MB, which is basically the size of the images reported in my app's settings + metadata of the object (small strings + bools)
Nov ’21
Reply to Why does CloudKit data field (bytes) take up more (~10 times) iCloud storage than asset field?
This is insane. I've been investigating this issue and I can reproduce it 100% of the time on my end. I have two methods in my code that I've added to debug this issue, one to calculate the size of the thumbnails and another one to delete them. Here are both of them: func allThumbnailsSize() -> String { let items = (try? self.container.viewContext.fetch(CDItem.fetchRequest())) ?? [] let size = items.reduce(0, { $0 + ($1.metadataThumbnail?.count ?? 0) }) let formatter = ByteCountFormatter() formatter.formattingContext = .middleOfSentence return formatter.string(fromByteCount: Int64(size)) } func deleteAllThumbnails() { let items = (try? self.container.viewContext.fetch(CDItem.fetchRequest())) ?? [] items.forEach { $0.metadataThumbnail = nil } self.saveIfNeeded() } And here's the property in the model: Here's a screenshot that clearly shows the problem, and how simply nullifying the property that is of type Binary Data in Core Data reduces the size ~10x on iCloud. Capture of the size in the settings of my app. The size is calculated using allThumbnailsSize() shown above. Capture of the size reported on iCloud for Abyss, my app. (Ignore the other Abyss record with 80.9MB, it's another iCloud Container for a migration) Capture of the size after tapping the Delete Thumbnails button. That button simply calls deleteAllThumbnails(). Capture of the size reported on iCloud for Abyss after a few minutes to let it sync. As shown on the images, the iCloud size is totally wrong. And it's not an issue on the iPhone only, checking the size on iCloud on my Mac, also reported 782.2 MB used. For apple folks, I've opened a feedback: FB9770168
Nov ’21
Reply to Is there any way to speed up filtering a SwiftUI List when searching?
@exCore Yes, it did lag, even when running from the App Store. And you're right, the .filter { _ in true } is uneeded, I just left it there by mistake because my original code was using @FetchRequest to get the data from Core Data instead of in memory, and it's needed in that case. I haven't tried the .animation(nil, value: searchQuery), I will and I'll report back, thanks for the tip. What did work for me, in case that anyone is reading this, is actually putting an .id(searchQuery) on the List itself. That way, every time that the searchQuery changes, the List is thrown away and recreated to avoid the diffing process.
Nov ’21
Reply to Why does CloudKit data field (bytes) take up more (~10 times) iCloud storage than asset field?
@DD21 Did you end up finding a solution? I'm using NSPersistentCloudKitContainer to have CloudKit + Core Data and I'm observing the same issue. I have saved ~6000K items in Core Data, which some of them have images. The local size for the sum of the images is around 76 MB, but if you check it on iPhone > Settings > Apple ID > iCloud > Manage Storage, it shows up as ~760 MB, which is the 10x increase in size that you reported a year ago. This seems to be a bug on the whatever's in charge of calculating the size for iCloud assets, because when I delete my app from my device and let it download all the information stored on iCloud again, it finishes the download extremely fast (I'm assuming because it's only downloading 76MB). If it were downloading 760MB, it would take much longer knowing my network connection speed. Now, if this bug actually affects user's iCloud quota (which it seems that it does), it is a large scale issue that might be impacting millions of users. Users might have much more iCloud storage space than they think because of this. cc // @eskimo
Nov ’21
Reply to Generate .webarchive on a WKWebView
It seems that "Discover WKWebView Enhancements - https://developer.apple.com/videos/play/wwdc2020/10188/" introduced exactly what I needed. I haven't had time to give it a try yet, but it looks exactly like what I was looking for. Thank you so much! 💖 Edit: I went to give it a try and it doesn't seem to be available in Beta 1. Value of type 'WKWebView' has no member 'createWebArchiveData' 🤞 for Beta 2!
Jun ’20
Reply to NSPersistentCloudKitContainer: Migrating multiple devices with data changes in between
I've been facing the same issue on my app and the only solution that I could come up so people don't have to suffer the out of sync issues is version the URL for the Core Data SQL file. This is terrible because after updating my users don't see their data until is fetched back from iCloud (entire sync because the local DB is new) but at least everything is 100% in sync between devices after updating on every device.
Jun ’20