Beta is the prerelease version of software or hardware.

Posts under Beta tag

200 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

SwiftData Bug with .modelContext in iOS 18
I'm using SwiftData to persist my items in storage. I used .modelContext to pass in my shared context, and on iOS 18 (both on a physical device and a simulator), I discovered a bug where SwiftData doesn't automatically save my data. For example, I could add a new item, go to the next screen, change something that reloads a previous screen, and SwiftData just forgets the item that I added. Please find the fully working code attached. While writing this post, I realized that if I use .modelContainer instead of .modelContext, the issue is solved. So I have two questions: It seems like .modelContainer is the go-to option when working with SwiftData, but why did an issue occur when I used .modelContext and passed in a shared container? When should we use .modelContext over .modelContainer? What was the bug? It's working fine in iOS 17, but not in iOS 18. Or is this expected? Here's the fully working code so you can copy and paste: import SwiftUI import SwiftData typealias NamedColor = (color: Color, name: String) extension Color { init(r: Double, g: Double, b: Double) { self.init(red: r/255, green: g/255, blue: b/255) } static let namedColors: [NamedColor] = [ (.blue, "Blue"), (.red, "Red"), (.green, "Green"), (.orange, "Orange"), (.yellow, "Yellow"), (.pink, "Pink"), (.purple, "Purple"), (.teal, "Teal"), (.indigo, "Indigo"), (.brown, "Brown"), (.cyan, "Cyan"), (.gray, "Gray") ] static func name(for color: Color) -> String { return namedColors.first(where: { $0.color == color })?.name ?? "Blue" } static func color(for name: String) -> Color { return namedColors.first(where: { $0.name == name })?.color ?? .blue } } @main struct SwiftDataTestApp: App { var sharedModelContainer: ModelContainer = { let schema = Schema([ Item.self, ]) let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false) do { return try ModelContainer(for: schema, configurations: [modelConfiguration]) } catch { fatalError("Could not create ModelContainer: \(error)") } }() @AppStorage("accentColor") private var accentColorName: String = "Blue" var body: some Scene { WindowGroup { NavigationStack { HomeView() } .tint(Color.color(for: accentColorName)) } .modelContainer(sharedModelContainer) // This works // .modelContext(ModelContext(sharedModelContainer)) // This doesn't work } } @Model final class Item { var timestamp: Date init(timestamp: Date) { self.timestamp = timestamp } } struct HomeView: View { @State private var showSettings = false @Environment(\.modelContext) var modelContext @AppStorage("accentColor") private var accentColorName: String = "Blue" @Query private var items: [Item] var body: some View { List { ForEach(items) { item in NavigationLink { Text("Item at \(item.timestamp, format: Date.FormatStyle(date: .numeric, time: .standard))") } label: { Text(item.timestamp, format: Date.FormatStyle(date: .numeric, time: .standard)) } } Button { withAnimation { let newItem = Item(timestamp: Date()) modelContext.insert(newItem) } } label: { Image(systemName: "plus") .frame(maxWidth: .infinity) .frame(maxHeight: .infinity) } } .navigationTitle("Habits") .toolbar { ToolbarItem(placement: .navigationBarTrailing) { Button(action: { showSettings = true }) { Label("", systemImage: "gearshape.fill") } } } .navigationDestination(isPresented: $showSettings) { colorPickerView } } private var colorPickerView: some View { Form { Section(header: Text("Accent Color")) { Picker("Accent Color", selection: $accentColorName) { ForEach(Color.namedColors, id: \.name) { namedColor in Text(namedColor.name) .tag(namedColor.name) .foregroundColor(namedColor.color) } } .pickerStyle(.wheel) } } .navigationTitle("Settings") } }
1
4
659
1w
macOS Sequoia Beta single-app mode bug
There was an option in macOS to show one app at a time with the user default like this: defaults write com.apple.dock single-app -bool true; killall Dock and it was very handy. But now it doesn't work. Is it deprecated or is this a bug? I know there is a Stage Manager and it has similar functionality, but it has some problems for me: It minimizes the previous app on opening another, and there is no way to show one app on top of the other, which was possible and handy with the Tab key with the single-app user default. This is handy when I run the Simulator on top of Xcode, but in general I want to minimize other apps when I click on an app in the Dock. There is no option to disable animations on the opening of the app. It leaves a small padding on the left side which is distracting (I like to use apps in full width). I have been using Stage Manager since the beta came out and still can't get used to it. And I actually turn it off when I start using Xcode.
0
0
313
Aug ’24
PreviewShell crashes and breaks the preview canvas
Since the first beta of Xcode 16, randomly when editing a SwiftUI view a crash report opens with the message "PreviewShell quit unexpectedly." After that, annoyingly often the canvas fails to reload correctly, and shows this broken thing: The only way to get it working again is to restart Xcode, but it happens so often that it really impacts productivity. Does this happen to anyone else? If so, have you found a solution? I've already filed a report (FB14876223)
8
8
1.5k
Sep ’24
Draw a physical mesh
In this code: https://developer.apple.com/documentation/visionos/incorporating-real-world-surroundings-in-an-immersive-experience It contains a physical collision reaction between virtual objects and the real world, which is realized by creating a grid with physical components. However, I don't understand the information in the document very well. Who can give me a solution? Thank you!
1
0
350
Aug ’24
iOS 18 beta 8 - Unable to verify
I have this problem since iOS 18 beta 7 and I couldn't install it either, it downloads correctly but when I try to install it shows "Unable to verify - iOS 18 beta 8 is temporarily unavailable. try again later" I've already deleted the update and downloaded it again, I restarted my phone, I reset the network settings, I have plenty space in my phone and still nothing. Does anyone know what to do?
0
0
409
Aug ’24
modelContext.fetchIdentifiers(descriptor) Errors when Using a SortDescriptor
modelContext.fetchIdentifiers(descriptor) errors when using a SortDescriptor to sort by a variable and returns no models. The fetch works fine without a SortDescriptor, thus FetchDescriptor<MyModel>() works fine, but FetchDescriptor<MyModel>(sortBy: [.init(\.title)]) or FetchDescriptor<MyModel>(sortBy: [SortDescriptor(\.title)]) errors with console message The operation couldn’t be completed. (SwiftData.SwiftDataError error 1.) I am using Xcode Version 16.0 beta 6 (16A5230g).
1
0
360
Aug ’24
iOS Developer BETA updates - not getting latest updates
HELP NEEDED! I'm part of the developer programme and have got iOS 18.1 (22B5023e) installed but I am not getting any of the latest updates, everything is setup on my device to receive them. Beta Updates - iOS 18 Developer Beta My Beta profile has disappeared from my iPhone 15 Pro Max but it won't allow me to install it again, I've downloaded from the developer site, click install, the iPhone restarts but the profile doesn't install, could this be the issue? Any help would be appreciated.
0
0
289
Aug ’24
HealthKit quantity types are not documented when generated by the system and on which Apple Watch models
Finally at last Apple Health supports saving .distancePaddleSports, .distanceCrossCountrySkiing, .distanceRowing, .distanceSkatingSports, and much more. The backstory. In the land of 10,000 lakes, there hasn't been a way to save 'canoe' or 'kayak' distance and I've been asking for it for years. Thank you health team for adding it this year! FB7807993 - Add HKQuantityTypeIdentifier.paddleDistance for canoeing, kayaking, etc type workouts (June 2020) Prior we could just save the totalDistance to a workout, but since the HKWorkout initializers were deprecated we no longer have a supported way to save these distances in our workouts. The iOS 18 / watchOS 11 introduction addresses this. If you want to know more why you can't do this in earlier versions you can check these feedback titles: FB10281482 - HealthKit: Deprecation of totalDistance on a workout session of paddleSports breaks apps that used that to save distance to the workout because there is no "paddleDistance" type available to save as sample data (June 2022) FB12402974 - HealthKit: Deprecation of HKWorkout completely breaks support for third party fitness apps from saving non-standard workout distance (June 2023) Great, so there is new support that solves all of these requests and issues for the new version of the OSes. However, the downside is now that there is not much for documentation. Unlike the .runningSpeed and .runningPower introduced in iOS 16 / watchOS 9, none of the new iOS 18 / watchOS 11 types have documentation, at all. To some degree this is understandable, but types from last year still remain undocumented too. Without this information for the data types introduced in both iOS 17/18 and watchOS 10/11 it makes building and integrating with these new types difficult to say the least. We can't make assumptions about anything. Can we get a documentation update for new (and existing) quantity types for when Apple Watch will automatically generate samples? FB14236080 - Developer Documentation / HealthKit: Update documentation for HKLiveWorkoutDataSource typesToCollect for which sample types are automatically collected by watchOS 10 and 11 (July 2024) FB14942555 - HealthKit / Documentation: App Update Release Issue - HKQuantityTypeIdentifiers are missing documentation describing when the system automatically adds data (today) I know that the behavior has changed from release to release for some of these types, so documentation would be based on OS version. If you didn't catch it, watchOS 11 will now associate .cyclingSpeed for cycling workouts both indoor and outdoor. FB12458548 - Fitness: Connected cycling speed sensor did not save samples to health via cycling workout (June 2023 - received reply that only saved for indoor cycling, but not documented otherwise) FB14311218 - HealthKit: Expected outdoor cycling to include .cyclingSpeed quantity type as a default HKLiveWorkoutDataSource type to collect (July 2024) To the other third party fitness apps out there, how are you managing the knowledge of which devices collect which data types on which versions of the OS? Sure, we could look at the HKLiveWorkoutDatSource and inspect the typesToCollect property across a bunch of devices, but again that is trial by error not 'as documented'. Is the behavior of simulators guaranteed to match the behavior of real devices? Maybe, but also maybe not. Fingers crossed for a nice documentation update to spell out all of the behavioral details. Apple folks / DTS, many of the above feedbacks are addressed and I plan to update or close them after the releases this fall. Some are still outstanding. P.S. I hope that .paddleSports gets deprecated and split into individual activity types like skiing did years ago. Their MET scores are different according to the research on the physical activity compendium site. FB7807902 - Split HKWorkoutActivityType.paddleSports into their own activity types (June 2020)
1
1
428
Oct ’24
Some question about Apple Intelligents
Apple Intelligents is here, but I have some problems. First of all, it often shows that something is being downloaded on the settings page. Is this normal? And the Predictive Code Completion Model in Xcode seems to have been suddenly deleted and needs to be re-downloaded, and the error The operation couldn't be complet has occurred. Ed. (ModelCatalog.CatalogErrors.AssetErrors error 1.), detailed log: The operation couldn’t be completed. (ModelCatalog.CatalogErrors.AssetErrors error 1.) Domain: ModelCatalog.CatalogErrors.AssetErrors Code: 1 User Info: { DVTErrorCreationDateKey = "2024-08-27 14:42:54 +0000"; } -- Failed to find asset: com.apple.fm.code.generate_small_v1.base - no asset Domain: ModelCatalog.CatalogErrors.AssetErrors Code: 1 -- System Information macOS Version 15.1 (Build 24B5024e) Xcode 16.0 (23049) (Build 16A5230g) Timestamp: 2024-08-27T22:42:54+08:00
2
3
594
Aug ’24
iOS 18 Bug: NavigationStack, paths, searchable and popping to root
Hello everyone, I wanted to post this as a sanity check before I create a Feedback for this bug. I'm using Xcode 16.1 Beta (167B5001e) along with iOS 18.1 Beta. When using a NavigationStack with a bindable path and navigating to another view while searching, it won't allow you to "pop to root" by resetting the path. Here's some simple code: // Base code from: // https://sarunw.com/posts/how-to-pop-to-root-view-in-swiftui/ import SwiftUI struct ContentView: View { @State private var path: [Int] = [] var body: some View { NavigationStack(path: $path) { Button("Start") { path.append(1) } .navigationDestination(for: Int.self) { int in DetailView(path: $path, count: int) } .navigationTitle("Home") } } } struct DetailView: View { @Binding var path: [Int] @State private var searchText = "" let count: Int var body: some View { Button("Go deeper") { path.append(count + 1) } .navigationBarTitle(count.description) .toolbar { ToolbarItem(placement: .bottomBar) { Button("Pop to Root") { path = [] } } } .searchable(text: $searchText) } } To reproduce: Start app and tap "Start". Tap "Go deeper" to push a couple views onto the stack. With any DetailView, tap the Search bar to make it active. While the search bar is active, tap "Go deeper" to push another view. Tap "Pop to root". You'll see that the path does indeed get reset, but the NavigationStack doesn't navigate anywhere. You're left with just empty views to go back to. Here's a link to a video from the simulator: https://streamable.com/m4bg5g The above video shows it working normally, then another run that uses the search bar to show the issue. Identical code works as normal on iOS 17. If anyone has any ideas, I'm all ears. Thank you for your time!
2
0
544
Aug ’24
Problem with a visionOS built with Xcode 16 and TestFlight
I developed an app for visionOS in Xcode 16 (the beta one). The app's deployment target is set to visionOS 1.2 in Xcode, which is also displayed in the app metadata in App Store Connect. Both debug and release builds deployed to a couple of authorised devices work. However, a build deployed to TestFlight refused to install, saying that VisionOS 2.0 is required. When I hacked a build with Xcode 15, it worked. Does it mean I cannot build apps for visionOS versions before 2.0 with Xcode 16?
0
0
298
Aug ’24
MacOS Sequoia tab bar issues (a bug also happens in tvOS 18)
I found two tab bar issues: How do you programmatically hide/show the tab bar for iPadOS and Catalyst apps under macOS Sequoia? Also, is there a way to prevent the user from doing this via the menu? Programmatically changing the current tab view correctly changes the tab view but not the tab item highlighted in the tab bar in: Mac Catalyst apps under Sequoia iPad apps under Sequoia tvOS 18 apps Is there a workaround I can use until this bug is fixed?
2
0
597
Aug ’24
SwiftData does not persist change on relationship on iOS 18 beta 7
I came across of something I'm struggling to comprehend. I've got an iOS app based on SwiftUI and SwiftData + CloudKit. I wrote it using Xcode 15 and the target was iOS 17. Everything works fine in this environment, but after upgrading my phone to iOS 18 beta 7 something very strange started to happen with SwiftData on a physical device and in the simulator. Every time when data is updated, to be precise - when the relationship is modified, the change is reverted after 15 seconds! I've got the following settings on and nothing can be seen it's going on there in the logs -com.apple.CoreData.Logging.stderr 1 -com.apple.CoreData.CloudKitDebug 1 -com.apple.CoreData.SQLDebug 1 -com.apple.CoreData.ConcurrencyDebug 1 Here you are some simplified code extraction: @Model final public class Note: Identifiable, Hashable { public private(set) var uuid = UUID().uuidString var notification: Notification? ... } @Model final public class Notification: Identifiable, Hashable { var dateId: String = "" @Relationship(deleteRule: .nullify, inverse: \Note.notification) var notes: [Note]? init(_ dateId: String) { self.dateId = dateId } } @ModelActor final public actor DataModelActor : DataModel { public func updateNotification(oldDate: Date, newDate: Date? = nil, persistentModelId: PersistentIdentifier) { if let note = modelContext.model(for: persistentModelId) as? Note { updateNotification(oldDate: oldDate, newDate: newDate, note: note) } try? self.modelContext.save() } private func updateNotification(oldDate: Date? = nil, newDate: Date? = nil, note: Note) { if let oldDate = oldDate { let notifications = fetchNotifications() let oldDateId = NotificationDateFactory.getId(from: oldDate) // removing the note from the collection related to oldDate if let notification = notifications.first(where: { $0.dateId == oldDateId }) { if let notificationNotes = notification.notes { if let notificationNoteIndex = notification.notes!.firstIndex(of: note) { notification.notes!.remove(at: notificationNoteIndex) } if notification.notes == nil || notification.notes!.isEmpty { self.modelContext.delete(notification) } } } } if let newDate = newDate, newDate > Calendar.current.startOfToday() { // adding to a new collection related to newDate let notifications = fetchNotifications() let newDateId = NotificationDateFactory.getId(from: newDate) if let notification = notifications.first(where: { $0.dateId == newDateId }) { note.notification = notification } else { let notification = Notification(newDateId) note.notification = notification } } } } Spreading save method here and there does not help :( I've used Core Data Lab software to look into database and I can clearly see data changes are reverted for relationship property. Example: In Notification database there is one element: 2024-08-26 (3) with 3 notes attached. I modified one note to send notification on 2024-08-27. Changes in database reflects situation correctly showing: 2014-08-26 (2) 2024-08-27 (1) BUT!!! After 15 seconds doing noting database looks like this: 2024-08-26 (3) 2024-08-27 (0) All changes were reverted and all notes are still attached to the same date as they were at the first place. Any thoughts?
3
1
765
Aug ’24
Reference Error for VisionOS
when I try to import CompositorServices, I get an error for: dyld[596]: Symbol not found: _$sSo13cp_drawable_tV18CompositorServicesE17computeProjection37normalizedDeviceCoordinatesConvention9viewIndexSo13simd_float4x4aSo0A26_axis_direction_conventionV_SitF Referenced from: /private/var/containers/Bundle/Application/33008953-150D-4888-9860-28F41E916655/VolumeRenderingVision.app/VolumeRenderingVision.debug.dylib Expected in: <968F7985-72C8-30D7-866C-AD8A1B8E7EE6> /System/Library/Frameworks/CompositorServices.framework/CompositorServices The app wrongly refers to my Mac's local directory. However, I chose Vision Pro as a running device. My Mac has been updated to macOS 15 beta 7, and I have not had the same issue before.
1
0
275
Aug ’24
iPadOS 18 TabView conflicts with NavigationSplitView
If you use the new TabView in conjunction with ".tabViewStyle(.sidebarAdaptable)" and have a NavigationSplitView in the tabs, the result is a very confusing user experience. When the TabView is displayed as tabs, there are two sidebar buttons. The left one closes/opens the sidebar of the view of the selected tab. The sidebar button of the Top-TabView closes/opens the sidebar for customizing the tabbar. However, this sidebar overlays the sidebar of the selected tab. To be able to use the underlying sidebar again, the user must actively close the TabView sidebar again (turn it into the top tabbar) Has anyone found ways to improve this behavior, or is this wrong by design? My expected behavior would be: If you use the new TabView with ".tabViewStyle(.sidebarAdaptable)" and have a two column NavigationSplitView in a tab, it automatically becomes a three column view when the top tabbar becomes a sidebar. import SwiftUI struct ContentView: View { var body: some View { TabView { Tab("Home", systemImage: "house") { HomeView() } Tab("Settings", systemImage: "gearshape") { Text("Settings") } } .tabViewStyle(.sidebarAdaptable) } } enum TabItem: String, Identifiable, CaseIterable { case first case second case third var id: String { rawValue } var content: String { rawValue } } struct HomeView: View { @State var selectedTab: String? var body: some View { NavigationSplitView { List(TabItem.allCases, selection: $selectedTab) { item in Text(item.content) } } detail: { if let selectedTab { Text("Detail: \(selectedTab)") } else { Text("Select an item") } } } }
4
2
552
Aug ’24
Request for Guidance on App Approval Process
We recently submitted our app, for approval, but unfortunately, it has not been approved. Our team has worked diligently to incorporate innovative ideas, fresh designs, and unique features that we believe offer significant value to users. We’ve carefully followed the guidelines and ensured that all aspects of the app, including user data safety and security, meet industry standards. Despite our efforts, we’ve encountered difficulties in getting the app approved. We would greatly appreciate your insights into the specific reasons for the denial and any areas that may require further improvement. Any sort of help or guidance will be much appreciated.
2
0
373
Aug ’24
PDFKit PDFPage.characterBounds(at:) returns incorrect coordinates iOS 18 beta 4
PDFKit PDFPage.characterBounds(at: Int) is returning incorrect coordinates with iOS 18 beta 4 and later / Xcode 16 beta 4. It worked fine in iOS 17 and earlier (after showing the same issue during the early iOS 17 beta cycle) It breaks critical functionality that my app relies on. I have filed feedback (FB14843671). So far no changes in the latest betas. iOS release date is approaching fast! Anybody having the same issue? Any workaround available?
7
1
807
2w
Navigation issue in Xcode 16 beta 7
I've got an iOS app and a main view with a list with a search field. When I click on a list item navigation link takes me to another view through navigation destination modifier. I can go back to the main list view. Now, consider this scenario: Click in the search field (you do not have to type there anything) Click any item on the list This all works fine when I build the app with Xcode 15.4 and I can get back to the main list. But if I build the app using Xcode 16 beta 7 the destination view is shown twice (the destination view is shown and then moved again to the same view) and I cannot back to the main view at all. I can go back one view only. Could it be a bug in Xcode? Was do you think about that?
3
0
494
Aug ’24