Post

Replies

Boosts

Views

Activity

Disable automatic iCloud sync with SwiftData
Is there a way to use SwiftData without automatic iCloud sync? I’d like to do that manually using my own CloudKit solution or CKSyncEngine. SwiftData automatically picks up any CloudKit containers though and I have not seen an option to disable this behavior. Setting cloudKitContainerIdentifier to nil does still pick the first available CloudKit container. Just in case this is a bug: FB12276416 Sample: let configuration = ModelConfiguration(cloudKitContainerIdentifier: nil) let modelContainer = try! ModelContainer(for: [GamesCollection.self], configuration) print(modelContainer.configurations) // [SwiftData.ModelConfiguration(url: …, name: …, sharedAppContainerIdentifier: …, cloudKitContainerIdentifier: Optional("iCloud.CloudKit.com.+++")
14
4
4.7k
Mar ’24
Stickers broken on iOS 18 / iPhone 16 after restoring from backup
[Detailed feedback FB15232205] Since I restored my new iPhone 16 Pro from a previous iPhone 15 Pro backup, I can't use stickers any more. The stickers gallery is filled with clear stickers that I can't interact with. Deleting does nothing. I also can't add new stickers. They appear for a second and then disappear again. iCloud sync is also not working. Other devices are fine. When restoring the phone without backup, everything works fine. Is it possible this is caused by the iOS 18.0 version that's shipping with the new iPhones? I was only offered another iOS 18.0 update in Settings later on. Updating to 18.1 beta 5 today did not fix it either. From what I gather from the logs, there's a database corruption happening. I've seen various posts across the internet who have this issue specifically after setting up their new iPhone. fehler 22:08:24.677501+0200 stickersd error: (11) Fatal error. The database at /private/var/mobile/Library/Stickers/stickers.stickerdb is corrupted. SQLite error code:11, 'database disk image is malformed' fehler 22:08:24.677615+0200 stickersd error: exception fetching row for object with ID: Fatal error. The database at /private/var/mobile/Library/Stickers/stickers.stickerdb is corrupted. SQLite error code:11, 'database disk image is malformed' with userInfo of { NSFilePath = "/private/var/mobile/Library/Stickers/stickers.stickerdb"; NSSQLiteErrorDomain = 11; } fehler 22:08:24.677679+0200 stickersd error: Unhandled error occurred during faulting: Error Domain=NSSQLiteErrorDomain Code=11 "(null)" UserInfo={NSFilePath=/private/var/mobile/Library/Stickers/stickers.stickerdb, NSSQLiteErrorDomain=11} ({ NSFilePath = "/private/var/mobile/Library/Stickers/stickers.stickerdb"; NSSQLiteErrorDomain = 11; }) fehler 22:08:24.677700+0200 stickersd fault: Unhandled error (NSSQLiteErrorDomain, 11) occurred during faulting and was ignored: Error Domain=NSSQLiteErrorDomain Code=11 "(null)" UserInfo={NSFilePath=/private/var/mobile/Library/Stickers/stickers.stickerdb, NSSQLiteErrorDomain=11} problem 22:08:24.677736+0200 stickersd CoreData: Unhandled error (NSSQLiteErrorDomain, 11) occurred during faulting and was ignored: Error Domain=NSSQLiteErrorDomain Code=11 "(null)" UserInfo={NSFilePath=/private/var/mobile/Library/Stickers/stickers.stickerdb, NSSQLiteErrorDomain=11} fehler 22:08:24.678107+0200 stickersd database corruption at line 79182 of [1b37c146ee] fehler 22:08:24.678757+0200 stickersd error: (11) Fatal error. The database at /private/var/mobile/Library/Stickers/stickers.stickerdb is corrupted. SQLite error code:11, 'database disk image is malformed' fehler 22:08:24.678783+0200 stickersd error: exception fetching row for object with ID: Fatal error. The database at /private/var/mobile/Library/Stickers/stickers.stickerdb is corrupted. SQLite error code:11, 'database disk image is malformed' with userInfo of { NSFilePath = "/private/var/mobile/Library/Stickers/stickers.stickerdb"; NSSQLiteErrorDomain = 11; } fehler 22:08:24.678807+0200 stickersd error: Unhandled error occurred during faulting: Error Domain=NSSQLiteErrorDomain Code=11 "(null)" UserInfo={NSFilePath=/private/var/mobile/Library/Stickers/stickers.stickerdb, NSSQLiteErrorDomain=11} ({ NSFilePath = "/private/var/mobile/Library/Stickers/stickers.stickerdb"; NSSQLiteErrorDomain = 11; }) fehler 22:08:24.678826+0200 stickersd fault: Unhandled error (NSSQLiteErrorDomain, 11) occurred during faulting and was ignored: Error Domain=NSSQLiteErrorDomain Code=11 "(null)" UserInfo={NSFilePath=/private/var/mobile/Library/Stickers/stickers.stickerdb, NSSQLiteErrorDomain=11} problem 22:08:24.678858+0200 stickersd CoreData: Unhandled error (NSSQLiteErrorDomain, 11) occurred during faulting and was ignored: Error Domain=NSSQLiteErrorDomain Code=11 "(null)" UserInfo={NSFilePath=/private/var/mobile/Library/Stickers/stickers.stickerdb, NSSQLiteErrorDomain=11} fehler 22:08:24.678878+0200 stickersd database corruption at line 79182 of [1b37c146ee] fehler 22:08:24.678903+0200 stickersd error: (11) Fatal error. The database at /private/var/mobile/Library/Stickers/stickers.stickerdb is corrupted. SQLite error code:11, 'database disk image is malformed' fehler 22:08:24.678931+0200 stickersd error: exception fetching row for object with ID: Fatal error. The database at /private/var/mobile/Library/Stickers/stickers.stickerdb is corrupted. SQLite error code:11, 'database disk image is malformed' with userInfo of { NSFilePath = "/private/var/mobile/Library/Stickers/stickers.stickerdb"; NSSQLiteErrorDomain = 11; } fehler 22:08:24.678953+0200 stickersd error: Unhandled error occurred during faulting: Error Domain=NSSQLiteErrorDomain Code=11 "(null)" UserInfo={NSFilePath=/private/var/mobile/Library/Stickers/stickers.stickerdb, NSSQLiteErrorDomain=11} ({ NSFilePath = "/private/var/mobile/Library/Stickers/stickers.stickerdb"; NSSQLiteErrorDomain = 11; }) fehler 22:08:24.678972+0200 stickersd fault: Unhandled error (NSSQLiteErrorDomain, 11) occurred during faulting and was ignored: Error Domain=NSSQLiteErrorDomain Code=11 "(null)" UserInfo={NSFilePath=/private/var/mobile/Library/Stickers/stickers.stickerdb, NSSQLiteErrorDomain=11}
12
9
5.5k
Oct ’24
UITabBarController, menu bar and first responder
I'm using a standard UITabBarController on iPad. When first selecting any tab, the corresponding menu bar items are grayed out for this view controller. It's only when I tap any button in that view controller, like in the toolbar, that the view controller truly becomes the first responder (you can see the sidebar selection turns to gray from blue), enabling those menu bar items. Am I doing something wrong here? A video of the issue can be found here: https://mastodon.social/@nicoreese/114949924393554961 AppDelegate: ... builder.insertChild(MenuController.viewModeMenu(), atStartOfMenu: .view) class func viewModeMenu() -> UIMenu { let listViewModeCommand = UICommand( title: String(localized: "As List"), image: UIImage(systemName: "list.bullet"), action: #selector(GamesViewController.setListViewMode), propertyList: SettingsService.ViewMode.list.rawValue ) ... let viewModeMenu = UIMenu( title: "", image: nil, identifier: .viewModeMenu, options: .displayInline, children: [listViewModeCommand...] ) return viewModeMenu } GamesViewController: @objc func setListViewMode() { updateViewMode(.list) } I can do this, but then the sidebar selection instantly turns gray, which looks odd and other system apps do not behave this way. override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) becomeFirstResponder() } override var canBecomeFirstResponder: Bool { return true }
Topic: UI Frameworks SubTopic: UIKit Tags:
5
0
200
Aug ’25
What is the scroll edge effect supposed to look like now?
At WWDC the scroll edge effect was presented as a variable blur combined with a soft gradient. Since beta 4 the bottom scroll edge effect has no blur, the top bar sometimes has, but sometimes does not. Even in my own app I have two views with totally different results. This was not changed back in beta 5, so I assume this is not a bug but an intended change. It's hard to design for such a moving target. Especially the missing bottom blur looks bad in a lot of places in my app and I'm debating not shipping the new design if this does not get resolved. Is there any guidance how this effect is supposed to look now? At this point it just seems random and there's no way adjust the way it looks. Phone: Top blur, bottom no blur Settings: Top blur, bottom no blur Notes: No blur at all Music: No blur at all My own app: No top blur My own app: Top blur
4
1
170
Aug ’25
UITabBarController ignores UITab view controllers when in UITabGroup
When composing tabs like this and selecting them in the sidebar, only the group's view controller is ever displayed, even when selecting the individual first and second tabs. Their view controllers are just ignored. Am I immensely stupid here or is this a bug in iPadOS 26 beta 3? // First tab let firstTab = UITab( title: "First", image: UIImage(systemName: "heart"), identifier: "hello" ) { _ in UINavigationController(rootViewController: ViewController()) } // Second tab let secondTab = UITab( title: "Second", image: UIImage(systemName: "heart"), identifier: "hello2" ) { _ in UIViewController() } // Tab group let tabGroup = UITabGroup( title: "Stuff", image: nil, identifier: "stuff", children: [firstTab, secondTab] ) { _ in ViewController() } let tbc = UITabBarController(tabs: [tabGroup]) tbc.mode = .tabSidebar
Topic: UI Frameworks SubTopic: UIKit
3
0
208
Jul ’25
Replacing the Preferences item in a menu bar
Per default the menu bar on iPad includes an application menu named after your app which includes a Preferences action. That one opens the Settings app to your app settings page. I do not really populate that with options and instead have my own settings UI accessible in my app using toolbar items. What's the best approach to handle this with the menu bar? I've tried replacing the default Preferences item but that only works if I do not use its shortcut, which I would like to preserve. Another solution would be to append another Settings item for my UI, which would look weird and confusing, but seems to be the recommended way from the HIG. Reserve the YourAppName > Settings menu item for opening your app’s page in iPadOS Settings. If your app includes its own internal preferences area, link to it with a separate menu item beneath Settings in the same group. Place any other custom app-wide configuration options in this section as well. I take it there is no way to replace it then?
Topic: UI Frameworks SubTopic: UIKit Tags:
3
0
140
Jul ’25
New typed notifications for keyboards do not work?
@MainActor class KeyboardObserver { var token: NotificationCenter.ObservationToken! func registerObserver(screen: UIScreen) { let center = NotificationCenter.default token = center.addObserver(of: screen, for: .keyboardWillShow) { keyboardState in print("+++ Keyboard showed up!") } } } The notification is never called. The sample code from the sessions also does not work for me. let keyboardObserver = NotificationCenter.default.addObserver( of: UIScreen.self for: .keyboardWillShow ) { message in UIView.animate( withDuration: message.animationDuration, delay: 0, options: .flushUpdates ) { // Use message.endFrame to animate the layout of views with the keyboard let keyboardOverlap = view.bounds.maxY - message.endFrame.minY bottomConstraint.constant = keyboardOverlap } } @MainActor class KeyboardObserver { func registerObserver(screen: UIScreen) { let center = NotificationCenter.default let token = center.addObserver( of: screen, for: .keyboardWillShow ) { keyboardState in let startFrame = keyboardState.startFrame let endFrame = keyboardState.endFrame self.keyboardWillShow(startFrame: startFrame, endFrame: endFrame) } } func keyboardWillShow(startFrame: CGRect, endFrame: CGRect) {} }
Topic: UI Frameworks SubTopic: UIKit Tags:
3
0
131
Aug ’25
How to create an overlay with padding that ignores the safe area?
Was it always so tricky to ignore the bottom safe area? Seems like iOS 26 makes this much harder. I've tried many variations of ignoresSafeArea, safeAreaInset, safeAreaBar, etc. Nothing seems to work. As soon as I add padding, the bottom safe area crashes the party. This is what I want to achieve: This is what I get right now: struct ContentView: View { var body: some View { List { Text("Content") } .overlay(alignment: .bottom) { content } } var content: some View { VStack { Text("Custom Container") } .frame(maxWidth: .infinity) .frame(height: 400) .background(Color.gray, in: .rect(corners: .concentric, isUniform: true)) .padding(15) } }
3
0
117
Aug ’25
PSA: UISceneDelegate.openURLContexts called twice sometimes in iOS 26
If you use UISceneDelegate's scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) to handle deep links (such as tapping a widget) you might run into an issue where this callback is called twice in the majority of cases. If you push a view controller in response to this, you might end up with two pushed view controllers, if you do not mitigate this. This is exclusively an issue in iOS 26.0 and works as expected on iOS 18. func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) { /// Add any widget to the home screen that uses the widgetURL modifier and tap them. Most of the time, openURLContexts() will get called twice. /// If you run this project on iOS 18, it's *always* called once as expected. print("openURLContexts \(URLContexts)") } Filed as FB20301454
3
2
225
Oct ’25
didRegisterForRemoteNotificationsWithDeviceToken called twice when also using CKSyncEngine in project
In didFinishLaunchingWithOptions I have this setup for getting the token to send to my server for notifications. The issue is that the delegate callback didRegisterForRemoteNotificationsWithDeviceToken gets called twice when also initializing a CKSyncEngine object. This confuses me. Is this expected behavior? Why is the delegate callback only called twice when both are called, but not at all when only using CKSyncEngine. See code and comments below. /// Calling just this triggers `didRegisterForRemoteNotificationsWithDeviceToken` once. UIApplication.shared.registerForRemoteNotifications() /// When triggering the above function plus initializing a CKSyncEngine, `didRegisterForRemoteNotificationsWithDeviceToken` gets called twice. /// This somewhat make sense, because CloudKit likely also registers for remote notifications itself, but why is the delegate not triggered when *only* initializing CKSyncEngine and removing the `registerForRemoteNotifications` call above? let syncManager = SyncManager() /// Further more, if calling `registerForRemoteNotifications` with a delay instead of directly, the delegate is only called once, as expected. For some reason, the delegate is only triggered when two entities call `registerForRemoteNotifications` at the same time? DispatchQueue.main.asyncAfter(deadline: .now() + 4) { UIApplication.shared.registerForRemoteNotifications() } func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { print("didRegisterForRemoteNotificationsWithDeviceToken") }
3
0
94
Nov ’25
SwiftUI Toolbar back button on macOS
I have a layout similar to Music or Podcasts, where I have a sidebar and a grid content area. When clicking on one of the items in the grid I want to open a full screen detail view just like Music does. My question is: How can I display a back button in the toolbar? I only figured out how to add buttons to the trailing side of the toolbar. Is this even possible in pure SwiftUI?  .toolbar {             Button(action: showSearch) {                 Label("Add Game", systemImage: "plus")             }         }
2
0
4.3k
Dec ’20
Core Data, Swift 6, Concurrency and more
I have the following struct doing some simple tasks, running a network request and then saving items to Core Data. Per Xcode 26's new default settings (onisolated(nonsending) & defaultIsolation set to MainActor), the struct and its functions run on the main actor, which works fine and I can even safely omit the context.perform call because of it, which is great. struct DataHandler { func importGames(withIDs ids: [Int]) async throws { ... let context = PersistenceController.shared.container.viewContext for game in games { let newGame = GYGame(context: context) newGame.id = UUID() } try context.save() } } Now, I want to run this in a background thread to increase performance and responsiveness. So I followed this session (https://developer.apple.com/videos/play/wwdc2025/270) and believe the solution is to mark the struct as nonisolated and the function itself as @concurrent. The function now works on a background thread, but I receive a crash: _dispatch_assert_queue_fail. This happens whether I wrap the Core Data calls with context.perform or not. Alongside that I get a few new warnings which I have no idea how to work around. So, what am I doing wrong here? What's the correct way to solve this simple use case with Swift 6's new concurrency stuff and the default main actor isolation in Xcode 26? Curiously enough, when setting onisolated(nonsending) to false & defaultIsolation to non isolating, mimicking the previous behavior, the function works without crashing. nonisolated struct DataHandler { @concurrent func importGames(withIDs ids: [Int]) async throws { ... let context = await PersistenceController.shared.container.newBackgroundContext() for game in games { let newGame = GYGame(context: context) newGame.id = UUID() // Main actor-isolated property 'id' can not be mutated from a nonisolated context; this is an error in the Swift 6 language mode } try context.save() } }
2
0
145
Jun ’25
iPad menu bar and multiple windows
I'm trying to support the new menu bar in iPadOS 26. In AppDelegate I do this. I want to this to be a global command, which can work regardless of which view controller is currently visible, so I let the AppDelegate handle the selector (if there's a better way let me know). UIMainMenuSystem.shared.setBuildConfiguration(config) { builder in let createCollectionCommand = UIKeyCommand( title: String(localized: "Create Collection"), image: UIImage(systemName: "folder.badge.plus"), action: #selector(AppDelegate.showCreateCollectionViewController), input: "c", modifierFlags: .control ) builder.insertElements([createCollectionCommand], atEndOfMenu: .file) } This works mostly. A problem arrises when I have multiple windows open at the same time. I need a way to determine the currently active window scene from AppDelegate to display a sheet on that window's root view controller. There's stuff like this, but unfortunately all visible windows have activationState == .foregroundActive, so I cannot use that. guard let scene = UIApplication.shared.connectedScenes.first(where: { $0.activationState == .foregroundActive }) as? UIWindowScene else { return } So, how do I do multi-window global commands? I'm basically looking for something like the "Create Playlist" command in the Music app.
Topic: UI Frameworks SubTopic: UIKit Tags:
2
0
134
Jul ’25