Post

Replies

Boosts

Views

Activity

Is this log noise? "CoreSVG: Error: NULL ref passed to getObjectCoreSVG: Error: NULL ref passed to getObject"
Before I waste time creating an Apple Developer Support ticket, I’m hoping an Apple DTS engineer can confirm if this is just log noise. Here’s the code: import SwiftUI struct ContentView: View { @State private var editMode: EditMode = .inactive @State private var items = ["Item 1", "Item 2", "Item 3"] var body: some View { NavigationStack { List { ForEach(items, id: \.self) { item in Text(item) } .onDelete { indexSet in items.remove(atOffsets: indexSet) } } .environment(\.editMode, $editMode) .toolbar { ToolbarItem(placement: .topBarTrailing) { EditButton() .environment(\.editMode, $editMode) } } } } } #Preview { ContentView() } When you run this code and tap Edit, you’ll initially get: CoreSVG has logged an error. Set environment variabe [sic] "CORESVG_VERBOSE" to learn more. After setting CORESVG_VERBOSE = YES, you’ll see: CoreSVG: Error: NULL ref passed to getObjectCoreSVG: Error: NULL ref passed to getObject This error only appears the first time Edit is tapped after a build and run. It won't happen again, even after force-quitting and reopening the app. The issue also only happens on iOS 18.0 and 18.1—I can’t reproduce it on iOS 17.5. Fortunately, it doesn’t seem to cause any negative side effects. Is this just log noise?
2
4
634
Oct ’24
How to build a top/bottom split view with a dynamically-sized divider?
Is there a way to structure three views vertically with a top, middle divider, and bottom view, where the… Middle divider view “hugs” its contents vertically (grows and shrinks based on height of child views) Top and bottom views fill the space available above and below the divider Divider can be dragged all the way up (or down), to completely hide the top view (or bottom view) I’ve been working on this for a while and still can’t get it quite right. The code below is close, but the parent view’s bottom edge shifts when the divider resizes. As a result, the bottom view shifts upward when the divider shrinks, whereas I want it to continue to fill the space to the bottom of the screen. import SwiftUI struct ContentView: View { @State private var topRatio: CGFloat = 0.5 @State private var dividerHeight: CGFloat = 44 var body: some View { GeometryReader { geometry in let topInset = geometry.safeAreaInsets.top let bottomInset = geometry.safeAreaInsets.bottom let totalHeight = geometry.size.height let availableHeight = max(totalHeight - bottomInset - dividerHeight, 0) VStack(spacing: 0) { TopView() .frame(height: max(availableHeight * topRatio - topInset, 0)) .frame(maxWidth: .infinity) .background(Color.red.opacity(0.3)) DividerView() .background(GeometryReader { proxy in Color.clear.preference(key: DividerHeightKey.self, value: proxy.size.height) }) .onPreferenceChange(DividerHeightKey.self) { height in dividerHeight = height } .gesture( DragGesture() .onChanged { value in let maxDragDistance = availableHeight + dividerHeight let translation = value.translation.height / max(maxDragDistance, 1) let newTopRatio = topRatio + translation topRatio = min(max(newTopRatio, 0), 1) } ) .zIndex(1) BottomView() .frame(height: max(availableHeight * (1 - topRatio), 0)) .frame(maxWidth: .infinity) .background(Color.green.opacity(0.3)) } } } } struct DividerHeightKey: PreferenceKey { static var defaultValue: CGFloat = 44 static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) { value = nextValue() } } struct DividerView: View { @State private var showExtraText = true var body: some View { VStack(spacing: 0) { Text(showExtraText ? "Tap to hide 'More'" : "Tap to show 'More'") .frame(height: 44) if showExtraText { Text("More") .frame(height: 44) } } .frame(maxWidth: .infinity) .background(Color.gray) .onTapGesture { showExtraText.toggle() } } } struct TopView: View { var body: some View { VStack { Spacer() Text("Top") } .padding(0) } } struct BottomView: View { var body: some View { VStack { Text("Bottom") Spacer() } .padding(0) } } #Preview { ContentView() }
2
0
281
Oct ’24
Simple SwiftData app exhibits excessive & persistent memory growth as items are added
[Submitted as FB14860454, but posting here since I rarely get responses in Feedback Assistant] In a simple SwiftData app that adds items to a list, memory usage drastically increases as items are added. After a few hundred items, the UI lags and becomes unusable. In comparison, a similar app built with CoreData shows only a slight memory increase in the same scenario and does NOT lag, even past 1,000 items. In the SwiftData version, as each batch is added, memory spikes the same amount…or even increases! In the CoreData version, the increase with each batch gets smaller and smaller, so the memory curve levels off. My Question Are there any ways to improve the performance of adding items in SwiftData, or is it just not ready for prime time? Example Projects Here are the test projects on GitHub if you want to check it out yourself: PerfSwiftData PerfCoreData
2
0
598
Aug ’24
How to avoid Swift 6 concurrency warning from UIAccessibility.post()
I have the following var in an @Observable class: var displayResult: String { if let currentResult = currentResult, let decimalResult = Decimal(string: currentResult) { let result = decimalResult.formatForDisplay() UIAccessibility.post(notification: .announcement, argument: "Current result \(result)") return result } else { return "0" } } The UIAccessiblity.post gives me this warning: Reference to static property 'announcement' is not concurrency-safe because it involves shared mutable state; this is an error in Swift 6 How can I avoid this?
3
0
1.5k
Jun ’24