Post

Replies

Boosts

Views

Activity

Toolbar Menu button seems to look disabled
Overview On macOS, in a NavigationSplitView when the menu button is added to the detail view toolbar, it seems to look disabled Environment Xcode: 14.1 beta 3 (14B5033e) macOS: 13.0 Beta (22A5365d) Code: struct ContentView: View { @State private var selectedNumber: Int? var body: some View { NavigationSplitView { List(0..<100, selection: $selectedNumber) { number in Text("cell \(number)") } } detail: { Text("Detail") .toolbar { ToolbarItem { Menu { Button("aa") {} Button("bb") {} } label: { Label("Add Bookmark", systemImage: "book") } } } } } } Steps to reproduce: Run the project on macOS Select cell 0 on the sidebar Click on the book toolbar button and notice the menu appear Select cell 1 on the sidebar Expected Behaviour After step 4, the book toolbar button should look prominent (like it is enabled) Actual Behaviour After step 4, the book toolbar button looks like it is disabled. Screenshot
1
1
1.6k
Nov ’23
FB11794798: NSPersistentCloudKitContainer throws lots of error / debug messages
Hi, When using NSPersistentCloudKitContainer lots of error / debug messages are shown in Xcode Debug area. Feedback FB11794798: Overview When I use NSPersistentCloudKitContainer I get the following error / debug messages printed on the Xcode Debug Area. Syncing seems to happen fine. Tested on device and simulator. I am still using Development (not deployed to Production yet) I even tried with a new project using the default code generated for by enabling CloudKit coredata sync and I still get the same messages. I have filed a feedback FB11794798 Steps to Reproduce Create a new project check Use CoreData and Host in CloudKit check boxes Run the project Notice the error messages shown below. Questions How to resolve these errors? Or is this a bug from the Apple Frameworks? (Feedback FB11794798) Error / debug message printed on Xcode debug area CoreData: debug: CoreData+CloudKit: -[PFCloudKitOptionsValidator validateOptions:andStoreOptions:error:](36): Validating options: <NSCloudKitMirroringDelegateOptions: 0x600000760510> containerIdentifier:<MyContainerID> databaseScope:Private ckAssetThresholdBytes:<null> operationMemoryThresholdBytes:<null> useEncryptedStorage:NO useDeviceToDeviceEncryption:NO automaticallyDownloadFileBackedFutures:NO automaticallyScheduleImportAndExportOperations:YES skipCloudKitSetup:NO preserveLegacyRecordMetadataBehavior:NO useDaemon:YES apsConnectionMachServiceName:<null> containerProvider:<PFCloudKitContainerProvider: 0x600003764210> storeMonitorProvider:<PFCloudKitStoreMonitorProvider: 0x600003764220> metricsClient:<PFCloudKitMetricsClient: 0x600003764230> metadataPurger:<PFCloudKitMetadataPurger: 0x600003764240> scheduler:<null> notificationListener:<null> containerOptions:<null> defaultOperationConfiguration:<null> progressProvider:<NSPersistentCloudKitContainer: 0x60000205d200> test_useLegacySavePolicy:YES archivingUtilities:<PFCloudKitArchivingUtilities: 0x600003764250> bypassSchedulerActivityForInitialImport:NO storeOptions: { NSInferMappingModelAutomaticallyOption = 1; NSMigratePersistentStoresAutomaticallyOption = 1; NSPersistentCloudKitContainerOptionsKey = "<NSPersistentCloudKitContainerOptions: 0x600003b3a190>"; NSPersistentHistoryTrackingKey = 1; NSPersistentStoreMirroringOptionsKey = { NSPersistentStoreMirroringDelegateOptionKey = "<NSCloudKitMirroringDelegate: 0x600000c642a0>"; }; NSPersistentStoreRemoteChangeNotificationOptionKey = 1; } CoreData: debug: CoreData+CloudKit: -[NSCloudKitMirroringDelegate observeChangesForStore:inPersistentStoreCoordinator:](416): <NSCloudKitMirroringDelegate: 0x600000c642a0>: Observing store: <NSSQLCore: 0x14080aec0> (URL: file:///Users/<my home folder>/Library/Group%20Containers/group.<app name>/<filename>.sqlite) CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _setUpCloudKitIntegration](562): <NSCloudKitMirroringDelegate: 0x600000c642a0>: Successfully enqueued setup request. CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate checkAndExecuteNextRequest](3209): <NSCloudKitMirroringDelegate: 0x600000c642a0>: Checking for pending requests. CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate checkAndExecuteNextRequest]_block_invoke(3222): <NSCloudKitMirroringDelegate: 0x600000c642a0>: Executing: <NSCloudKitMirroringDelegateSetupRequest: 0x600001643f20> D3975DD0-1198-40F2-9D6A-B9994B9710B6 CoreData: debug: CoreData+CloudKit: -[PFCloudKitMetadataModelMigrator calculateMigrationStepsWithConnection:error:](446): Skipping migration for 'ANSCKDATABASEMETADATA' because it already has a column named 'ZLASTFETCHDATE'
0
1
1.4k
Nov ’22
Developer app on the Mac doesn't play videos in full screen
Hi, Problem When playing videos on the Developer app on the Mac, there is no full screen button for the video. So it is not possible to play the video in full screen. Note I am not referring to the app going into full screen, the issue is with there is no option to play the video in full screen. Environment OS: macOS 26.2 (25C56) Developer app: Version 10.8.3 (1083.3.1) Feedback FB21343934 Recording Question Are others also facing this issue? Is there a workaround? Suggestion This seems to be recurring problem that seems get broken with app / OS releases. Please write some UI tests to ensure the full screen button is present. Would really appreciate if this gets fixed.
6
5
300
4d
Logger on Xcode console
Overview: I am logging some messages using Logger I would like these messages to be printed on to Xcode without the timestamp and other details I want only the message to be displayed Questions: How can I display only the message on the Xcode console (see preferred output)? Is there a setting in Xcode to remove the timestamp prefix? Is there an alternate approach? Note: I need to use Logger because this app would be released, so print is not an option. Example Code import SwiftUI import os struct ContentView: View { let logger = Logger(subsystem: "MyApp", category: "MyCategory") var body: some View { Text("Hello, world!") .onAppear { logger.debug("content view displayed") } } } Actual Output: 2022-11-25 18:41:10.116408+0800 Demo[36175:5518724] [MyCategory] content view displayed Preferred Output: One of the following would be ideal: content view displayed Demo[36175:5518724] [MyCategory] content view displayed My Failed Attempt I event tried to use print in debug mode, but couldn't make it compile: Following is my failed attempt: import os #if DEBUG struct Logger { let subsystem: String let category: String func debug(_ message: String) { print(message) } //This will not help: // func debug(_ message: OSLogMessage) { // print(message) // } } #endif
4
1
4.7k
Nov ’22
SwiftData Query relationships not working
Overview I have 2 models: Deparment and Student Each Department can contain multiple students Each Student can only be in one Department I have DepartmentList, tapping on the department should take it to the StudentList which lists all students in the department Problem When I use Query in StudentList to filter only students for a specific department id, no students are shown. Questions: What should I do to list the students in a department? (see complete code below). let filter = #Predicate<Student> { student in student.department?.id == departmentID } let query = Query(filter: filter, sort: \.name) _students = query Complete code App @main struct SchoolApp: App { var body: some Scene { WindowGroup { ContentView() } .modelContainer(for: [Department.self, Student.self]) } } Department import Foundation import SwiftData @Model class Department { var id: UUID var name: String var students: [Student] init( id: UUID, name: String, students: [Student] = [] ) { self.id = id self.name = name self.students = students } } Student import Foundation import SwiftData @Model class Student { var id: UUID var name: String @Relationship(inverse: \Department.students) var department: Department? init( id: UUID, name: String, department: Department? = nil ) { self.id = id self.name = name self.department = department } } ContentView import SwiftUI struct ContentView: View { @State private var selectedDepartment: Department? var body: some View { NavigationSplitView { DepartmentList(selectedDepartment: $selectedDepartment) } detail: { if let department = selectedDepartment { StudentList(department: department) } else { Text("no department selected") } } .task { printStoreFilePath() } } private func printStoreFilePath() { let urls = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask) if let path = urls.map({ $0.path(percentEncoded: false) }).first { print("Storage: \(path)") } } } DepartmentList import SwiftUI import SwiftData struct DepartmentList: View { @Binding var selectedDepartment: Department? @Query(sort: \.name) private var departments: [Department] @Environment(\.modelContext) private var modelContext var body: some View { List(selection: $selectedDepartment) { ForEach(departments) { department in NavigationLink(value: department) { Text(department.name) } } } .toolbar { ToolbarItem { Button { addDepartment() } label: { Label("Add", systemImage: "plus") } } } } private func addDepartment() { guard let index = (1000..<10000).randomElement() else { return } let department = Department(id: UUID(), name: "Department \(index)") modelContext.insert(department) } } StudentList import SwiftUI import SwiftData struct StudentList: View { var department: Department @Query private var students: [Student] @Environment(\.modelContext) private var modelContext init(department: Department) { self.department = department let departmentID = department.id let filter = #Predicate<Student> { student in student.department?.id == departmentID } let query = Query(filter: filter, sort: \.name) _students = query } var body: some View { List { ForEach(students) { student in Text(student.name) } } .toolbar { ToolbarItem { Button { addStudent() } label: { Label("Add", systemImage: "plus") } } } } private func addStudent() { guard let index = (1000..<10000).randomElement() else { return } let student = Student( id: UUID(), name: "Student \(index)", department: department ) modelContext.insert(student) } }
10
4
4k
Jul ’23
NavigationStack and NavigationSplitView Runtime warnings
Overview: When running the demo code presented in "The SwiftUI cookbook for navigation" (https://developer.apple.com/wwdc22/10054) I ran into some issues: Runtime warnings: 2022-06-08 22:20:31.587169+0800 NavigationSplitViewDemo[17797:672165] [SwiftUI] A NavigationLink is presenting a value of type “Category” but there is no matching navigation destination visible from the location of the link. The link cannot be activated. onChange(of: UpdateTrigger) action tried to update multiple times per frame. 2022-06-08 22:15:23.432289+0800 NavigationSplitViewDemo[17645:662571] [UIFocus] _TtGC7SwiftUI14_UIHostingViewGVS_15ModifiedContentVS_7AnyViewVS_12RootModifier__ implements focusItemsInRect: - caching for linear focus movement is limited as long as this view is on screen. Feedback filed: FB10103041 and FB10104196
13
4
8.3k
Aug ’22