Post

Replies

Boosts

Views

Activity

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
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
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
defaultIsolation option and Core Data
When creating a new project in Xcode 26, the default for defaultIsolation is MainActor. Core Data creates classes for each entity using code gen, but now those classes are also internally marked as MainActor, which causes issues when accessing managed object from a background thread like this. Is there a way to fix this warning or should Xcode actually mark these auto generated classes as nonisolated to make this better? Filed as FB13840800. nonisolated struct BackgroundDataHandler { @concurrent func saveItem() async throws { let context = await PersistenceController.shared.container.newBackgroundContext() try await context.perform { let newGame = Item(context: context) newGame.timestamp = Date.now // Main actor-isolated property 'timestamp' can not be mutated from a nonisolated context; this is an error in the Swift 6 language mode try context.save() } } } Turning code gen off inside the model and creating it manually, with the nonisolated keyword, gets rid of the warning and still works fine. So I guess the auto generated class could adopt this as well? public import Foundation public import CoreData public typealias ItemCoreDataClassSet = NSSet @objc(Item) nonisolated public class Item: NSManagedObject { }
1
0
94
Jun ’25
Core Data crash when used in widget extension
I have this very simple PersistenceController setup. It's used in both the main app and widget target. struct PersistenceController { static let shared = PersistenceController() @MainActor static let preview: PersistenceController = { let result = PersistenceController(inMemory: true) let viewContext = result.container.viewContext return result }() let container: NSPersistentContainer /// The main context. var context: NSManagedObjectContext { return container.viewContext } init(inMemory: Bool = false) { container = NSPersistentContainer(name: "Gamery") if inMemory { container.persistentStoreDescriptions.first!.url = URL(fileURLWithPath: "/dev/null") } else { do { let storeURL = try URL.storeURL(forAppGroup: "XXXXXXXXXX", databaseName: "Gamery") let storeDescription = NSPersistentStoreDescription(url: storeURL) /// Enable history tracking for cloud syncing purposes. storeDescription.setOption(true as NSNumber, forKey: NSPersistentHistoryTrackingKey) print("### Persistent container location: \(storeURL)") container.persistentStoreDescriptions = [storeDescription] } catch { print("Failed to retrieve store URL for app group: \(error)") } } container.loadPersistentStores(completionHandler: { (storeDescription, error) in if let error = error as NSError? { Crashlytics.crashlytics().record(error: error) fatalError("Unresolved error \(error), \(error.userInfo)") } }) container.viewContext.automaticallyMergesChangesFromParent = true container.viewContext.mergePolicy = NSMergePolicy.mergeByPropertyObjectTrump #if !WIDGET if !inMemory { do { try container.viewContext.setQueryGenerationFrom(.current) } catch { fatalError("###\(#function): Failed to pin viewContext to the current generation: \(error)") } } PersistentHistoryToken.loadToken() #endif } } I regularly receive crash logs from the widget. I never experienced crashes myself and the widgets work fine. GameryWidgetExtension/PersistenceController.swift:35: Fatal error: Unresolved error Error Domain=NSCocoaErrorDomain Code=256 "The file “Gamery.sqlite” couldn’t be opened." UserInfo={NSFilePath=/private/var/mobile/Containers/Shared/AppGroup/B6A63FE1-ADDC-4A4C-A065-163507E991C6/Gamery.sqlite, NSSQLiteErrorDomain=23}, ["NSSQLiteErrorDomain": 23, "NSFilePath": /private/var/mobile/Containers/Shared/AppGroup/B6A63FE1-ADDC-4A4C-A065-163507E991C6/Gamery.sqlite] I have absolutely no idea what's going on here. Anyone who can help with this?
1
1
126
Jul ’25
Pushing a UIHostingController has delayed toolbar items and title transitions
For over five years, this persistent issue has affected all platforms, and despite submitting numerous feedback reports, my concerns have remained unaddressed. When utilizing a UIHostingController within a UINavigationController, the toolbar items and title defined in the SwiftUI view manifest with a substantial delay. This delay is particularly noticeable with the introduction of Liquid Glass, resulting in a jarring transition. Although I had nearly lost hope, the issue was resolved in iOS 26 beta 3 when the push occurs from within a UISplitViewController. However, the problem persists outside of this context. Ultimately, this issue hinders my ability to develop high-quality applications and restricts my use of SwiftUI within my UIKit project for similar purposes. I sincerely hope that this issue can be resolved, enabling me to fully rely on SwiftUI in my project. Please prioritize this matter and make the necessary changes that were already made in UISplitViewController. This feedback has all the details and a sample project. FB14000542 Before the push: During the push: A second after the push finishes:
0
1
147
Jul ’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
What to do about the new glass medium detent sheets
So many issues with the new sheet design, I don't think I can ship these. And it's both in UIKit and SwiftUI. Honestly these net sheets seem like a failure from start to finish and I don't believe it will get better for the initial release. Toolbar buttons in medium detent size have very low contrast and look bad with their opaque appearance During the transition from medium to large detent the whole sheet flickers and turns transparent for a split moment, creating a very jarring transition (video here: https://mastodon.social/@nicoreese/114938826906689965). In the large detent the background is always white in light mode making the cells bleed into the background making them indistinguishable from it. I should be able to set a background color for the large detent which smoothly transitions to it. Like: glass in medium and system grouped background in large. Any interaction with the medium detent sheet makes it scale up. Why? It's okay for single interactions but not for when the user taps something in it rapidly. There needs to be a way to disable this behavior. In the medium detent List/UICollectionView rows are white in light mode or gray in dark mode. Especially in dark mode it looks very bad against the glass background. Those rows should probably be translucent to better fit the glass. This needs serious fixing and fast. FB18919680 FB18919657 FB18919600 FB18919549 FB18919496 FB18919630
0
1
104
Jul ’25
Context menus need option to disable morphing
For some controls it is desirable to not use the morphing transition when presenting a Menu. Instead, you might want to have the old behavior, where the menu is presented above or below the initiating view. This can be the case for any other control than toolbar items, but especially for bigger content cards, that should trigger a menu upon tapping it once. In those cases it looks weird and does not really help to keep context of what the action is doing. Is there some way to do this right now? In case it's not, I also filed a feedback. FB18413055
0
0
82
Jul ’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
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
UISearchTab with automaticallyActivatesSearch only works on second tap?
let searchTab = UISearchTab { tab in UINavigationController(rootViewController: SearchViewController()) } searchTab.automaticallyActivatesSearch = true class SearchViewController: UIViewController { private let searchController = UISearchController(searchResultsController: UIViewController()) override func viewDidLoad() { super.viewDidLoad() navigationItem.searchController = searchController } } With this setup when I launch the app and tap the search tab, the keyboard will not appear. Switching tabs and tapping search again works from then on. Am I doing something wrong here? Video here: https://mastodon.social/@nicoreese/114983627125286299
Topic: UI Frameworks SubTopic: UIKit Tags:
2
0
108
Aug ’25