Post

Replies

Boosts

Views

Activity

Generate .webarchive on a WKWebView
Is there any way to generate a .webarchive from iOS? I know that WKWebView can render them without any issues (generated them on macOS for example), but it seems that there's no API to generate one from iOS itself. It seems that not so long ago such feature became available on WebKit, but it's not yet available to the public API of WKWebView: https://github.com/WebKit/webkit/commit/7bc9562269dacab6b75833e3d00be3c4f616bfd4 Would Apple consider making such API public? I'm assuming that it's what's being used on the Reading List to save articles offline.
5
1
2.5k
Jun ’20
Is it safe to use a NSPersistentCloudKitContainer on a Share Extension?
I have an app that uses NSPersistentCloudKitContainer to store all the data so it's backed by iCloud and synced between devices. Such app has a Share Extension, that can be triggered both from iOS (and iPadOS) and macOS (Catalyst). I was wondering if it's safe to instantiate an NSPersistentCloudKitContainer from a Share Extension due to it being very short lived. At the moment, I'm sending the data straight to iCloud instead of instantiating an NSPersistentCloudKitContainer, but it feels wrong because I'm using the keys that NSPersistentCloudKitContainer created internally (CD_MyEntity, CD_myProperty, etc.) to send it to iCloud and then being correctly pulled by my clients. The only concern that I have is that bringing up an NSPersistentCloudKitContainer that has to pull data, might delay or even loose the data that I'm saving right now because it gets killed after some amount of time since the share action has been completed. Any insights will be much appreciated, because if it's safe to use an NSPersistentCloudKitContainer from a Share Extension, I could remove a ton of fragile code! 🙏
3
0
1.9k
Jun ’20
Is there any way to observe the sync status of an NSPersistentCloudKitContainer?
I believe that right now there's no way to be notified when the sync status of an NSPersistentCloudKitContainer changes. Is my assumption correct? I'd like to know if there are pending changes to be synced or when the sync starts/ends to be able to reflect it on the UI to inform my users. Any ideas on how (or if it's possible) to achieve what I need? Thank you!
1
0
965
Jul ’20
Do unique constraints work on an NSPersistentCloudKitContainer?
The documentation - https://developer.apple.com/documentation/coredata/mirroring_a_core_data_store_with_cloudkit/creating_a_core_data_model_for_cloudkit for Creating a Core Data Model for CloudKit states that Unique constraints aren’t supported. but I've tried to set one up and it seems to be working fine (locally, I haven't tried syncing yet) on Xcode 11.5 & iOS 13.5. If I'm not mistaken, when NSPersistentCloudKitContainer was first introduced Xcode displayed an error if you tried to add a constraint to an Entity, but that doesn't seem to happen anymore. Has this restriction been lifted or do I just remember it incorrectly and it never showed any errors? If the restriction has not been lifted, does anyone know how to make sure that Entities are not duplicated? It'll be easy to add a cleanup operation after every sync, but so far I am not aware of any way to know when the sync has fully finished - https://developer.apple.com/forums/thread/652607. Thanks.
0
0
620
Jul ’20
@FetchRequest is not updated when Core Data is saved from another process (Share Extension)
I have an app that has a main target, a Share Extension and an App Extension. I save data from any of the extensions, but the UI is never updated on the main app when going back into it if the app was on the background (alive, not terminated). If the app was terminated, it all works as expected because it loads everything from scratch. If the app was on the background, it's not updated until a save from an unrelated part of the code occurs. It feels like @FetchRequest's is not aware of remote (meaning from other processes) changes, is this something that has to be done manually? I have both suggested options enabled: storeDescription.setOption(true as NSNumber, forKey: NSPersistentHistoryTrackingKey) storeDescription.setOption(true as NSNumber, forKey: NSPersistentStoreRemoteChangeNotificationPostOptionKey) When using UIKit with an NSFetchedResultsController, you could simply call performFetch to force the refresh of the controller when the app became active, but I don't see a way to force a refresh on a @FetchRequest.
1
2
1.2k
Nov ’21
Is there any way to force the presentation of a Share Extension's UIViewController to use UISheetPresentationController?
I'm wondering if there's any way to force the UIViewController presented by a Share Extension to use the UISheetPresentationController introduced in iOS 15? Right now, the only way they're presented is modally, occupying almost the entire screen. Most share extensions don't need that much space and would allow you to have more context from where you shared (the originating app).
1
0
1.6k
Nov ’21
Is there any way to speed up filtering a SwiftUI List when searching?
I'm having a lot of performance issues with SwiftUI Lists and I can't seem to find any solution. Currently, if you have a List with 10_000 items and try to filter it, the app hangs for 1 second at the beginning of filtering, looking at Instruments it seems to be an issue with the underlying UITableView to perform the animations. Here's a very tiny example to demo the issue: struct Item: Identifiable, Hashable {     let title: String     var id: String { title } } @main struct ListFilteringDemoApp: App {     private let allItems = (0...10_000).map { _ in Item(title: UUID().uuidString) }     @State var searchQuery: String = ""     var filteredItems: [Item] {         if searchQuery.isEmpty {             // No filter applied             return allItems.filter { _ in true }         } else {             return allItems.filter { item in item.title.localizedCaseInsensitiveContains(searchQuery)             }         }     }     var body: some Scene {         WindowGroup {             NavigationView {                 List(filteredItems) { item in                     Text(item.title).id(item)                 }                 .navigationTitle("Filtering")                 .searchable(text: $searchQuery, placement: .navigationBarDrawer(displayMode: .always))             }         }     } } I know that having 10_000 items in an array is not common. But using Core Data with a @FetchRequest, having 10_000 items is very easy to achieve for the kind of app that I'm building, and the issue is the same. The issue is present on device (iPhone 12 Pro, iOS 15.1), macOS and iOS Simulator. I've two questions: Is there a better way to filter a list while searching? If the answer is no, is there any way to prevent the animations on a List while being filtered to try to improve the performance? Thanks! PS: For Apple folks, I've opened a feedback which includes a sample project to reproduce the issue and a saved Instruments .trace. Number: FB9763003
3
0
1.5k
Nov ’21
App Store Connect doesn't allow me to include new In App Purchases for review
I'm really struggling with having two new In-App Purchases approved. I've added two new IAPs in the V2 of my app, but for some reason they're never approved, they keep coming back to me with the "Developer Action Needed" error and "We have returned your IAP product/s to you as the required binary was not submitted. When you are ready to submit the binary, please resubmit the IAPs with the binary." I have, indeed, included the code to handle them on the binary being submitted (working fine on dev & TestFlight). I remember that when I added the first ever purchase I had to include it where you select which binary needs to be reviewed, but that option never appears. Here's how it's looking: There's nowhere to select any In-App Purchase to be reviewed with that binary. I've peeked at the console and I'm seeing 404's for a URL that might be exactly what I need, is the App Store Connect just broken right now? I've tried everything and I haven't been able to find what's shown here: https://help.apple.com/app-store-connect/#/dev1986a0e5c
1
0
989
Nov ’21
SwiftUI List on macOS prematurely loads every row
I'm observing a weird issue with SwiftUI Lists on macOS (they do work as expected on iOS). The problem is that the List calls the init & body of every row, even if those rows are not on screen (and might never be shown). If I replace the List with a ScrollView + LazyVStack, it does work as expected (only those rows which are going to be rendered get their init & body called). Of course, this is is not an ideal workaround because you loose the built-in benefits of using a List (mainly selection in my case). I did expect that under the hood, SwiftUI would use the same mechanism as NSTableView (which loads cells on demand). Historically I'm an iOS dev, so I'm used to cellForRowAtIndexPath coming from UITableView. Here's a quick gist demonstrating the issue: import SwiftUI @main struct SwiftUIListVSLazyVStackApp: App {     let numbers = (0...100).map { $0 }     var body: some Scene {         WindowGroup {             /*              List calls the init & the body of *every* element on the list, even if it's not being displayed.              This is unexpected because a tableView usually only loads the visible cells as needed (cellForRowAtIndexPath)              */             List(numbers) { number in                 RowView(for: number, example: "list")             }             /*              A combination of ScrollView + LazyVStack achieves what's expected from the list. Only calls the init & body of              the element that's going to be displayed.              */ //            ScrollView { //                LazyVStack(alignment: .leading, spacing: 8) { //                    ForEach(numbers) { number in //                        RowView(for: number, example: "stack") //                    } //                } //            }         }     } } struct RowView: View {     private let number: Int     private let example: String     init(for number: Int, example: String) {         print("Init \(example): \(number)")         self.number = number         self.example = example     }     var body: some View {         let _ = print("Body \(example): \(number)")         Text("\(number)")             .onAppear{ print("Appear \(example): \(number)") }     } } extension Int: Identifiable {     public var id: Int { self } } GitHub gist: https://gist.github.com/xmollv/7ecc97d8118c100e85698c5ff09a20dc And a video to better show the issue if you can't run the code: https://gist.github.com/xmollv/7ecc97d8118c100e85698c5ff09a20dc?permalink_comment_id=4140623#gistcomment-4140623 Twitter thread: https://twitter.com/xmollv/status/1517158777882955779 Any help is very much appreciated!
0
0
804
Apr ’22
SwiftUI apps on macOS don't relaunch after being minimized
I've been working on a macOS app using pure SwiftUI, and I've found a strange behavior that I've no idea how to solve. If you have enabled the System Preferences > Dock & Menu Bar > Minimize windows into application icon flag, when you minimize the window it never launches again when clicking the app icon on the dock. This does not happen with an AppKit application. The issue can be seen here (video + 2 sample projects): https://github.com/xmollv/macOSMinimizeIssueOnSwiftUI Literally they're empty apps, just created them using Xcode's assistant (the SwiftUI one has the steps to repro the issue in the UI). The only solution that I found to launch the SwiftUI one is rick clicking the app icon, and then selecting the window, but of course nobody expects that. My question is: is there any way launch a minimized SwiftUI app when clicking the dock icon?
3
0
2.5k
May ’22
SwiftUI's contextMenu(forSelectionType:menu:primaryAction:) returns an incorrect amount of rows if the selection is manually modified
I'm facing a weird issue with contextMenu(forSelectionType:menu:primaryAction:) attached to a List. It works fine if you enable edit mode, and start selecting the rows by tapping, but if you have a button that what it does is manually modify the selection, the returned rows when the contextMenu is invoked is incorrect. Furthermore, if you use the select all button, but actually scroll to the bottom of the list, the returned values is correct, so it seems that unless the cell is rendered, the contextMenu won't return it. Does anybody know if I'm doing something wrong? Here's a quick example to reproduce the issue: struct ContentView: View {     let rows = (0..<100).map{ "Row: \($0)" }     @State var selection: Set<String> = []     var body: some View {         List(selection: $selection) {             ForEach(rows, id: \.self) { row in                 Text(row).tag(row)             }         }.contextMenu(forSelectionType: String.self) { contextMenuRows in             Button("Number of rows in the contextMenu: \(contextMenuRows.count)") {}         }.toolbar {             ToolbarItem(placement: .navigationBarLeading) {                 if selection.isEmpty {                     Button("Select All") { selection = Set(rows) }                 } else {                     Button("Deselect All") { selection = [] }                 }             }             ToolbarItem(placement: .navigationBarTrailing) {                 EditButton()             }         }     } } Make sure to embed the ContentView inside a NavigationView to be able to see the navigation bar. Video demo showing the issue: https://imgur.com/a/fxKk5Cs Works fine when selecting manually When selecting all only displays the first 9 rows After scrolling, all rows are available to the contextMenu
0
0
883
Sep ’22
Extraneous alignment of a SwiftUI.Menu when animated by the keyboard appearing
I'm facing a weird alignment issue with a floating menu when the keyboard appears and I've no idea if there's a workaround. To reproduce the issue, simply copy and paste this code: struct ContentView: View {     @State var searchQuery = ""          var customToolbarButton: some View {         VStack {             Text("Example").font(.footnote)             Image(systemName: "arrowtriangle.down.fill").imageScale(.small)         }.foregroundColor(.accentColor)     }          var body: some View {         NavigationView {             Rectangle().fill(.red)             .safeAreaInset(edge: .bottom) {                 HStack(alignment: .center) {                     customToolbarButton                     Spacer()                     Menu { } label: {                         customToolbarButton                     }                 }                 .frame(height: 52)                 .padding(.horizontal)                 .background(Color.white)                 .clipShape(Capsule(style: .continuous))             }         }.searchable(text: $searchQuery)     } } When the keyboard appears and moves the HStack up, the views that are a Menu are wrongly placed, all other views seem fine. Any idea if there's a fix? Video to illustrate the issue: https://twitter.com/xmollv/status/1616851571832229889
0
0
545
Jan ’23
Xcode Cloud failure - The Build - iOS action could not complete due to an error. Something went wrong and the Xcode Cloud team has been notified to investigate. The error may not occur on rebuild.
Since last night we've been seeing this error on every build: The Build - iOS action could not complete due to an error. Something went wrong and the Xcode Cloud team has been notified to investigate. The error may not occur on rebuild. Is there anything that we can do? Every build fails now. Thanks.
8
3
1.6k
Mar ’23
ITMS-90382: Upload limit reached
We've started hitting this limitation when submitting builds using Xcode Cloud. ITMS-90382: Upload limit reached - The upload limit for your application has been reached. Please wait 1 day and try again. We generate TestFlight builds for every PR (builds from PR get sent to QA & devs) & for every merge (builds get sent to everybody in the team). Is there any way to know what's the limit so we can try to work around it? Edit: I've just checked, and TestFlight only reports 19 builds that are expiring in 90 days (aka were uploaded within the last 24h). Is the limit that low?
3
3
2.1k
Mar ’23