Hello, my production app is experiencing some crashes according to app store analytics. I cannot seem to reproduce it.
According to Xcode Orginzer the app is crashing
10 SwiftUI 0x000000018ec372a0 PlatformViewHost.updateNestedHosts(_:colorSchemeChanged:) + 332 (PlatformViewHost.swift:699)
Distributor ID: com.apple.AppStore
Hardware Model: iPhone13,4
Version: 2.0.3 (86)
AppStoreTools: 15E204
AppVariant: 1:iPhone13,4:16
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd [1]
OS Version: iPhone OS 17.4.1 (21E236)
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Termination Reason: SIGNAL 6 Abort trap: 6
Triggered by Thread: 0
Kernel Triage:
VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter
VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter
VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter
VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter
VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter
Thread 0 name:
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x00000001d1bd6974 __pthread_kill + 8 (:-1)
1 libsystem_pthread.dylib 0x00000001e56590ec pthread_kill + 268 (pthread.c:1717)
2 libsystem_c.dylib 0x0000000191627c14 __abort + 136 (abort.c:159)
3 libsystem_c.dylib 0x0000000191627b8c abort + 192 (abort.c:126)
4 libswiftCore.dylib 0x000000018832a690 swift::fatalErrorv(unsigned int, char const*, char*) + 136 (Errors.cpp:387)
5 libswiftCore.dylib 0x000000018832a6b0 swift::fatalError(unsigned int, char const*, ...) + 32 (Errors.cpp:395)
6 libswiftCore.dylib 0x0000000188324a08 getNonNullSrcObject(swift::OpaqueValue*, swift::TargetMetadata<swift::InProcess> const*, swift::TargetMetadata<swift::InProcess> const*) + 256 (DynamicCast.cpp:144)
7 libswiftCore.dylib 0x0000000188326510 tryCastToObjectiveCClass(swift::OpaqueValue*, swift::TargetMetadata<swift::InProcess> const*, swift::OpaqueValue*, swift::TargetMetadata<swift::InProcess> const*, swift::TargetMetadata<swift::InPro... + 88 (DynamicCast.cpp:510)
8 libswiftCore.dylib 0x0000000188324068 tryCast(swift::OpaqueValue*, swift::TargetMetadata<swift::InProcess> const*, swift::OpaqueValue*, swift::TargetMetadata<swift::InProcess> const*, swift::TargetMetadata<swift::InProcess> const*&, sw... + 992 (DynamicCast.cpp:2281)
9 libswiftCore.dylib 0x0000000188323b14 swift_dynamicCast + 208 (CompatibilityOverrideRuntime.def:109)
10 SwiftUI 0x000000018ec372a0 PlatformViewHost.updateNestedHosts(_:colorSchemeChanged:) + 332 (PlatformViewHost.swift:699)
11 SwiftUI 0x000000018ec36bf4 PlatformViewHost.updateEnvironment(_:viewPhase:) + 412 (PlatformViewHost.swift:690)
12 SwiftUI 0x000000018ec37bf8 PlatformViewHost.init(_:host:environment:viewPhase:importer:) + 808 (PlatformViewHost.swift:132)
13 SwiftUI 0x000000018ec36cf8 PlatformViewHost.__allocating_init(_:host:environment:viewPhase:importer:) + 92 (PlatformViewHost.swift:0)
14 SwiftUI 0x000000018ec0132c closure #1 in closure #1 in closure #4 in closure #1 in PlatformViewChild.updateValue() + 444 (PlatformViewRepresentable.swift:559)
15 SwiftUI 0x000000018ec06c58 partial apply for closure #1 in closure #1 in closure #4 in closure #1 in PlatformViewChild.updateValue() + 24 (<compiler-generated>:0)
16 SwiftUI 0x000000018ea26910 RepresentableContextValues.asCurrent<A>(do:) + 156 (RepresentableContextValues.swift:43)
17 SwiftUI 0x000000018ec01124 closure #1 in closure #4 in closure #1 in PlatformViewChild.updateValue() + 176 (PlatformViewRepresentable.swift:558)
18 SwiftUI 0x000000018ec0104c closure #4 in closure #1 in PlatformViewChild.updateValue() + 128 (PlatformViewRepresentable.swift:557)
19 SwiftUI 0x000000018ec06b2c partial apply for closure #4 in closure #1 in PlatformViewChild.updateValue() + 24 (<compiler-generated>:0)
20 SwiftUI 0x000000018de7b7d0 closure #1 in _withObservation<A>(do:) + 44 (ObservationUtils.swift:26)
21 SwiftUI 0x000000018ec06b50 partial apply for closure #1 in _withObservation<A>(do:) + 24 (<compiler-generated>:0)
22 libswiftCore.dylib 0x0000000187fd0068 withUnsafeMutablePointer<A, B>(to:_:) + 28 (LifetimeManager.swift:82)
23 SwiftUI 0x000000018ebffbdc closure #1 in PlatformViewChild.updateValue() + 3040 (PlatformViewRepresentable.swift:556)
24 SwiftUI 0x000000018d5ecbf8 partial apply for implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:) + 32 (<compiler-generated>:0)
25 AttributeGraph 0x00000001b2150240 AG::Graph::UpdateStack::update() + 512 (ag-graph-update.cc:578)
26 AttributeGraph 0x00000001b2146f38 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int) + 424 (ag-graph-update.cc:719)
27 AttributeGraph 0x00000001b2146810 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, unsigned int, AGSwiftMetadata const*, unsigned char&, long) + 720 (ag-graph.cc:1429)
SwiftUI
RSS for tagProvide views, controls, and layout structures for declaring your app's user interface using SwiftUI.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Dear Sirs,
I'm writing an audio application that should show up to 128 horizontal peakmeters (width for each is about 150, height is 8) stacked inside a ScrollViewReader. For the actual value of the peakmeter I have a binding to a CGFloat value. The peakmeter works as expected and is refreshing correct. For testing I added a timer to my swift application that is firing every 0.05 secs, meaning I want to show 20 values per second. Inside the timer func I'm just creating random CGFloat values in range of 0...1 for the bound values. The peakmeters refresh and flicker as expected but I can see a CPU load of 40-50% in the activity monitor on my MacBook Air with Apple M2 even when compiled in release mode. I think this is quite high and I'd like to reduce this CPU load. Should this be possible? I.e. I thought about blocking the refresh until I've set all values? How could this be done and would it help? What else could I do?
Thanks and best regards,
JFreyberger
Is there a system deep link URI to the built in files app? I would like to direct users to my apps location in the files app. For example files://myApp
The only exposed deep links for system I can find are the ones for mail, sms, FaceTime etc.
Thank you
(tag used for post was because I couldn’t find a deep link tag)
Hi,
I have a List and I want to limit the dynamic text size for some of the elements in the list's row item view. I created a test view below. The ".dynamicTypeSize(.large)" restriction only works if it's applied to the List view, not if it's set for the the ContentItemView in the ForEach below.
Is there a reason for this? Do I need to do something else to limit a list row to a certain size? The example only has a text field, but I want to do this for a Image with some text inside it, and I wanted to restrict that text field, but it doesn't seem to work when the view is inside a List row.
Please let me know if there's a workaround for it.
import SwiftUI
import CoreData
struct ContentView: View {
@FetchRequest(
sortDescriptors: [NSSortDescriptor(keyPath: \Item.timestamp, ascending: true)],
animation: .default)
private var items: FetchedResults<Item>
@State private var multiSelectedContacts = Set<Item.ID>()
var body: some View {
NavigationStack {
List (selection: $multiSelectedContacts) {
ForEach(items) { item in
ContentItemView(item: item)
}
.dynamicTypeSize(.large) // <-- doesn't works
}
.dynamicTypeSize(.large) // <-- THIS WORKS
}
}
}
struct ContentItemView: View {
@Environment(\.managedObjectContext) private var viewContext
@ObservedObject var item: Item
@State var presentConfirmation = false
var body: some View {
HStack {
if let timestamp = item.timestamp, let itemNumber = item.itemNumber {
Text("\(itemNumber) - \(timestamp, formatter: itemFormatter)")
}
}
.popover(isPresented: $item.canShowPopover, content: {
Text("Test Item Label")
.frame(width: 100, height: 150)
})
}
}
private let itemFormatter: DateFormatter = {
let formatter = DateFormatter()
formatter.dateStyle = .short
formatter.timeStyle = .long
return formatter
}()
#Preview {
ContentView().environment(\.managedObjectContext, PersistenceController.preview.container.viewContext)
}
Hello, I am working on an application that utilizes both AppDelegate and SceneDelegate. We are looking to convert the top level app to SwiftUI and start using the SwiftUI App lifecycle. When implementing, I see that deep links when the app is backgrounded will only route to the onOpenURL modifier. This means that information we relied on before like referrerURL and annotation present in the NSUserActivity object delivered to the app is no longer available. Is there any work around for this? It seems like missing functionality because there is no way to route the deep links through AppDelegate or SceneDelegate if you are using the SwiftUI App protocol.
I have a small app written in SwiftUI and using SwiftData. It's been performing well for around a month but now suddenly I am getting the error below.
No changes have been made to the models in use. Looking at the error it appears to be when SwiftData commits data but how can I tell what it is trying (and failing) to commit? Some way of knowing the model being referenced would help me diagnose this further. The error occurs at random intervals, though I'm guessing that's partly reflected by the design of SwiftData?
[error] error: SQLCore dispatchRequest: exception handling request: <NSSQLSaveChangesRequestContext: 0x60000376af40> , -[__NSDictionaryM UTF8String]: unrecognized selector sent to instance 0x60000022adc0 with userInfo of (null)
CoreData: error: SQLCore dispatchRequest: exception handling request: <NSSQLSaveChangesRequestContext: 0x60000376af40> , -[__NSDictionaryM UTF8String]: unrecognized selector sent to instance 0x60000022adc0 with userInfo of (null)
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDictionaryM UTF8String]: unrecognized selector sent to instance 0x60000022adc0'
*** First throw call stack:
(
0 CoreFoundation 0x00000001804ae138 __exceptionPreprocess + 172
1 libobjc.A.dylib 0x0000000180087db4 objc_exception_throw + 56
2 CoreFoundation 0x00000001804c2f88 +[NSObject(NSObject) instanceMethodSignatureForSelector:] + 0
3 CoreFoundation 0x00000001804b2288 forwarding + 1280
4 CoreFoundation 0x00000001804b45ac _CF_forwarding_prep_0 + 92
5 CoreData 0x0000000186537b90 -[NSSQLiteConnection execute] + 1104
6 CoreData 0x0000000186534b58 -[NSSQLiteConnection updateRow:forRequestContext:] + 1848
7 CoreData 0x0000000186634378 _executeSaveChangesRequest + 2216
8 CoreData 0x000
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDictionaryM UTF8String]: unrecognized selector sent to instance 0x60000022adc0'
*** First throw call stack:
(
0 CoreFoundation 0x00000001804ae138 __exceptionPreprocess + 172
1 libobjc.A.dylib 0x0000000180087db4 objc_exception_throw + 56
2 CoreFoundation 0x00000001804c2f88 +[NSObject(NSObject) instanceMethodSignatureForSelector:] + 0
3 CoreFoundation 0x00000001804b2288 forwarding + 1280
4 CoreFoundation 0x00000001804b45ac _CF_forwarding_prep_0 + 92
5 CoreData 0x0000000186537b90 -[NSSQLiteConnection execute] + 1104
6 CoreData 0x0000000186534b58 -[NSSQLiteConnection updateRow:forRequestContext:] + 1848
7 CoreData 0x0000000186634378 _executeSaveChangesRequest + 2216
8 CoreData 0x000000018661e5e8 -[NSSQLSaveChangesRequestContext executeRequestCore:] + 28
9 CoreData 0x000000018641b28c -[NSSQLStoreRequestContext executeRequestUsingConnection:] + 248
10 CoreData 0x00000001864b4df4 __52-[NSSQLDefaultConnectionManager handleStoreRequest:]_block_invoke + 56
11 CoreData 0x000000018652d790 __37-[NSSQLiteConnection performAndWait:]_block_invoke + 40
12 libdispatch.dylib 0x00000001016e573c _dispatch_client_callout + 16
13 libdispatch.dylib 0x00000001016f648c _dispatch_lane_barrier_sync_invoke_and_complete + 144
14 CoreData 0x000000018652d248 -[NSSQLiteConnection performAndWait:] + 132
15 CoreData 0x00000001864b4d14 -[NSSQLDefaultConnectionManager handleStoreRequest:] + 204
16 CoreData 0x00000001865f29f4 -[NSSQLCoreDispatchManager routeStoreRequest:] + 220
17 CoreData 0x00000001864fa280 -[NSSQLCore dispatchRequest:withRetries:] + 168
18 CoreData 0x00000001864fc9e4 -[NSSQLCore executeRequest:withContext:error:] + 2116
19 CoreData 0x00000001864c6a84 __65-[NSPersistentStoreCoordinator executeRequest:withContext:error:]_block_invoke.383 + 9184
20 CoreData 0x00000001864bbac4 -[NSPersistentStoreCoordinator _routeHeavyweightBlock:] + 216
21 CoreData 0x00000001864c3ec8 -[NSPersistentStoreCoordinator executeRequest:withContext:error:] + 1100
22 CoreData 0x000000018647c8f8 -[NSManagedObjectContext save:] + 968
23 SwiftData 0x00000001cb408450 _swift_destroy_boxed_opaque_existential_0Tm + 50180
24 SwiftData 0x00000001cb4168d4 block_destroy_helper + 132
25 CoreData 0x00000001863cfec4 $sxs5Error_pIgrzo_xsAA_pIegrzo_lTR + 20
26 CoreData 0x00000001863d2198 $sxs5Error_pIgrzo_xsAA_pIegrzo_lTRTA + 20
27 CoreData 0x00000001863d1c8c $sSo22NSManagedObjectContextC8CoreDataE30_rethrowsHelper_performAndWait33_A0F63BA25A751D403694B89F4AD0A24ELL2fn7execute6rescuexyyyXEXE_xyKXExs5Error_pKXEtKlFyxyKcXEfU_yyXEfU + 108
28 CoreData 0x00000001863d04a4 $sIg_Ieg_TR + 20
29 CoreData 0x00000001863d04f4 $sIeg_IyB_TR + 20
30 CoreData 0x000000018648584c developerSubmittedBlockToNSManagedObjectContextPerform + 156
31 CoreData 0x0000000186485728 -[NSManagedObjectContext performBlockAndWait:] + 212
32 CoreData 0x00000001863d203c $sSo22NSManagedObjectContextC8CoreDataE14performAndWaityxxyKXEKlF + 352
33 SwiftData 0x00000001cb407b60 __swift_destroy_boxed_opaque_existential_0Tm + 47892
34 SwiftData 0x00000001cb4077a8 __swift_destroy_boxed_opaque_existential_0Tm + 46940
35 SwiftData 0x00000001cb40789c __swift_destroy_boxed_opaque_existential_0Tm + 47184
36 Foundation 0x0000000180e12924 __NSFireTimer + 56
37 CoreFoundation 0x000000018040f588 CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION + 28
Suggestions for narrowing down the cause gratefully accepted :-)
Topic:
UI Frameworks
SubTopic:
SwiftUI
Hello,
I want to detect when a ScrollView is scrolled at the top of a specific View in a LazyVStack. Here is the code I use:
struct ContentView: View {
@State private var scrollID: Int?
var body: some View {
HStack {
VStack {
Text(scrollID?.formatted() ?? "Unknown")
Button("Go") {
withAnimation {
scrollID = 7
}
}
Divider()
ScrollView {
LazyVStack(spacing: 300) {
ForEach(0...100, id: \.self) { int in
Text(int.formatted())
.frame(maxWidth: .infinity)
.background(.red)
}
}
.scrollTargetLayout()
}
.scrollPosition(id: $scrollID, anchor: .top)
}
}
}
}
As I specify a top anchor, I was expecting to see the scrollID binding being updated when the red Text View is at the top of the ScrollView. But I noticed that scrollPosition updates the binding way before the red Text View is positioned at the top of the ScrollView, which is not what I want.
In this image, you can see the binding is already at one even though there is a lot of space between the View and the top of the ScrollView. Maybe the Stack spacing is taken into account?
And manually setting the binding scroll at the position I want, just above the red Text for 7, which makes me think the views IDs are correct.
Is my understanding wrong about this modifier?
How can I detect the top (beginning) of the View?
(If this is a SwiftUI bug, I filed #FB13811349)
Hello!
I'm using PasteButton to set the value of a Binding<String>, and even though I'm using @MainActor, I'm getting a purple warning.
When I set a breakpoint, I can see that my function is not called on the main thread.
Due to the varying number of days in each month, I am unsure how to enable monthly paging in Charts.
In Apple's official example, SwiftChartsExample, there is only an example showing the sales of the "last 30 days":
.chartXVisibleDomain(length: 3600 * 24 * 30)
I have tried using scrollPosition to calculate the number of days in the current month, like this:
var days: Int {
let current = Calendar.current
let dateRange = current.range(of: .day, in: .month, for: scrollPosition)
return dateRange?.count ?? 0
}
...
.chartXVisibleDomain(length: 3600 * 24 * days)
...
.chartScrollPosition(x: $scrollPosition)
...
But I found that it does not work as expected. 😢
I'm showing several Steppers in a SwiftUI view on watchOS.
When the user taps the steppers & turns the digital crown it's possible to select multiple of the steppers (green "focus" border) appears.
I've tried to make the steppers mutually exclusive by using the following snippet, but it didn't work.
`@FocusState private var value: StepperType?`
[...]
var body: some View {
Form {
ForEach(StepperType.allCases, id: \.self) { stepperCase in
Stepper...
.focused($value, equals: stepperCase)
}
}
}
Any ideas how I can prevent multiple Steppers from being "focused" by the crown at the same time?
In my visionOS app, I have an initial WindowGroup (no parameters), which opens correctly on application launch. I have multiple other WindowGroup(for:) closures in the app, too.
If I open one of the other WindowGroup(for:) windows, then close the initial window, I can't get the initial window back. If I close the second window, then tap on app icon, the second window reappears, but the initial window isn't shown.
The only way to get the initial window back, once it's closed, is to force-quit the app and restart.
A one-file reproducible example is below. In this example, the "button tapped" window is the second window. What do I need to do to get the initial window back?
Note this problem is in a visionOS app. But I've been able to reproduce even if I remove the RealityKitContent package from the target.
If I close, say, Safari's only window, then Safari exits, and shows me its window when I relaunch. The behavior I'd like to see is that when I "click" the app icon, the app presents its main window again.
I have also tried giving the WindowGroup an id. That does allow me to openWindow from another window (could use a toolbar item for that), but it doesn't get the main window to appear on launch, and I end up with multiple copies of the Main window.
import SwiftUI
@main
struct Limbo_MREApp: App {
var body: some Scene {
// I've also tried this form, same result
// WindowGroup(id: "main") {
WindowGroup {
ContentView()
}
WindowGroup(for: String.self) { $string in
if let string {
Text(string)
.font(.extraLargeTitle2)
}
}
}
}
struct ContentView: View {
@Environment(\.openWindow) var openWindow
var body: some View {
VStack {
Text("Hello, world!")
Button("Tap Me", systemImage: "doc.on.doc") {
openWindow(value: "button tapped")
}
}
}
}
I’d like to create a simple Gantt chart where each horizontal BarMark is a navigation link to a detail view.
When I embed a navigation link within a chart, I get the error
“Static method 'buildExpression' requires that 'some ChartContent' conform to 'View’”
NavigationLink(value: taskGroup) {
BarMark(
xStart: .value("Start", taskGroup.start),
xEnd: .value("End", taskGroup.end),
y: .value("Event", taskGroup.taskGroupName),
height: barHeight
)
}
I could use a chart overlay and manage the navigation from there, but it appears I can only grab published chart data at a given tap gesture. I need the object itself to inject into the detail view (in this case TaskGroup) and the data I’m plotting in the chart isn’t unique - so no obvious way to identify which TaskGroup the user tapped.
iOS app running in compatibility mode on Apple Vision Pro does not apply hoverEffect to SwiftUI View
We tested our iOS app on visionOS and found that the hover effect works on most of UIKit views, but it does not work on most of SwiftUI views.
SwiftUI views are used within UIHostingController.
I created a new project (Storyboard based iOS app) and displayed the following SwiftUI view in UIHostingController and found that the buttons in the List were highlighted, but not the standalone buttons.
struct SwiftUIView: View {
var body: some View {
List {
// This button has the hover effect.
Button {
print("Hello")
} label: {
Text("Hello")
}
}
// This button does't have the hover effect.
Button {
print("Hello")
} label: {
Text("Hello")
}
.hoverEffect()
}
}
Is there a way to highlight any SwiftUI view?
Hi
I have an enum of the TextFields in an Update SwiftData view. When the view opens, the focus is correct, and the button in the .toolbar keyboard sets the focus to nil and dismisses the keyboard. It works just fine.
But, if I tap on a different TextField other than the original field that the focus was set in a .onAppear, the button on the keyboard dims out and no longer works.
This same code works as expected in another view, the only difference in the Update view is that the data in the fields comes from an @Bindable variable.
Any clue what is going on?
Thanks so much!
Blessings,
--Mark
Topic:
UI Frameworks
SubTopic:
SwiftUI
Some data have skipped dates, as in the following data.
TrainingSession(date: formatter.date(from: "2024-05-12 07:37:30 +0000")!, maxRM: 10.0, totalVolume: 0.0),
TrainingSession(date: formatter.date(from: "2024-06-01 15:00:00 +0000")!, maxRM: 10.5, totalVolume: 105.0),
TrainingSession(date: formatter.date(from: "2024-06-03 15:00:00 +0000")!, maxRM: 10.0, totalVolume: 100.0)
In this case, the graph shows nothing for the corresponding date as shown in the image.
s it possible to create a continuous graph by displaying only the data with values and not the dates with no values?
The source code is as follows
// ContentView.swift
// GraphSample
//
// Created by 齋藤卓馬 on 2024/06/09.
//
import SwiftUI
import Charts
struct TrainingSession {
var date: Date
var maxRM: Double
var totalVolume: Double
}
struct GraphView: View {
var sessions: [TrainingSession]
var body: some View {
ScrollView {
VStack(alignment: .leading) {
// 最大RMのグラフ
VStack(alignment: .leading) {
Text("最大RM")
.font(.headline)
.padding()
Chart(sessions, id: \.date) { session in
BarMark(
x: .value("Date", session.date),
y: .value("Max RM", session.maxRM)
)
}
.chartXAxis {
AxisMarks(values: .stride(by: .day, count:7)) // 日付の表示間隔を調整
}
.chartScrollableAxes(.horizontal) // 横スクロールを有効にする
.padding([.leading, .trailing, .bottom])
}
// 総負荷量のグラフ
VStack(alignment: .leading) {
Text("総負荷量")
.font(.headline)
.padding()
Chart(sessions, id: \.date) { session in
BarMark(
x: .value("Date", session.date),
y: .value("Total Volume", session.totalVolume)
)
}
.chartXAxis {
AxisMarks(values: .stride(by: .day, count:7)) // 日付の表示間隔を調整
}
.chartScrollableAxes(.horizontal) // 横スクロールを有効にする
.padding([.leading, .trailing, .bottom])
}
}
}
}
}
struct ContentView: View {
var body: some View {
GraphView(sessions: sampleData)
}
var sampleData: [TrainingSession] {
let formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-dd HH:mm:ss Z"
return [
TrainingSession(date: formatter.date(from: "2024-05-12 07:37:30 +0000")!, maxRM: 10.0, totalVolume: 0.0),
TrainingSession(date: formatter.date(from: "2024-06-01 15:00:00 +0000")!, maxRM: 10.5, totalVolume: 105.0),
TrainingSession(date: formatter.date(from: "2024-06-03 15:00:00 +0000")!, maxRM: 10.0, totalVolume: 100.0)
]
}
}
struct MyApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
Hello,
I face an error everytime I want to interact with a TextField. The XCode debug area is showing :
CLIENT ERROR: TUINSRemoteViewController does not override -viewServiceDidTerminateWithError: and thus cannot react to catastrophic errors beyond logging them
There is no crash, and the text field is working fine.
I am developing for MacOS using a macbook pro Intel from 2019 with Sonoma 14.5 and Xcode 15.4 and I think that I noticed since the release of Sonoma. I was not particularly concerned by it but I noticed that interacting with the textField was leading to severe hang in my app, and micro-hang in the test app and I am wondering is these two issues could be related.
The message is easy to reproduce. Just create a new Project/Application/App using SwiftUI and add a TextField to the ContentView.
When you start app, click or double click on the text field, enter a message and press enter.
import SwiftUI
struct ContentView: View {
@State var value: String = ""
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
TextField(text: $value,
label: {
Text("Test")
}
)
}
.padding()
}
}
Did you notice the same thing ? How I could solve it ?
Note : I already posted the problem on Swift forums but it was close because related to SwiftUI https://forums.swift.org/t/error-when-clicking-on-textfield-client-error-tuinsremoteviewcontroller-does-not-override-viewservicedidterminatewitherror-and-thus-cannot-react-to-catastrophic-errors-beyond-logging-them/72134/1
Thank you
I was hoping for an update of SwiftData which adopted the use of shared and public CloudKit containers, in the same way it does for the private CloudKit container.
So firstly, a big request to any Apple devs reading, for this to be a thing!
Secondly, what would be a sensible way of adding a shared container in CloudKit to an existing app that is already using SwiftData?
Would it be possible to use the new DataStore method to manage CloudKit syncing with a public or shared container?
The exact error is: Unable to create bundle at URL (file:///System/Library/CoreServices/SystemVersion.bundle): does not exist or not a directory (0).
I've defined a custom layout container by having a struct conform to Layout and implementing the appropriate methods, and it works as expected.
The problem comes when trying to display Image, as they are shown squished when just using the .resizable() view modifier, not filling the container when using .scaledToFit() or extending outside of the expected bounds when using .scaledToFill().
I understand that this is the intended behaviour of these modifiers, but I would like to replicate UIImageView's scaledAspectFill.
I know that this can usually be achieved by doing:
Image("adriana-wide")
.resizable()
.scaledToFill()
.frame(width: 200, height: 200)
.clipped()
But hardcoding the frame like that defeats the purpose of using the Layout, plus I wouldn't have direct access to the correct sizes, either.
The only way I've managed to make it work is by having a GeometryReader per image, so that the expected frame size is known and can bet set, but this is cumbersome and not really reusable.
GalleryGridLayout() {
GeometryReader { geometry in
Image("adriana-wide")
.resizable()
.scaledToFill()
.frame(width: geometry.size.width, height: geometry.size.height)
.clipped()
}
[...]
}
Is there a more elegant, and presumably efficient as well as reusable, way of achieving the desired behaviour?
Here's the code of the Layout.
My app randomly crashes with the error "Could not cast value of type 'CALayer' to 'SwiftUI.ColorShapeLayer'. Unfortunately the crash is not reproducible and happens rather randomly. I think the reason lies in the SwiftUI ProgressView that I show in my app using a UIHostingViewController as the rest of my app is basically built in UIKit. Here is the code for the ProgressView in question:
public struct CircularProgressView: View {
@State private var progress: Double = 0
public var body: some View {
ZStack(alignment: .center) {
SwiftUI.Color(.white)
Circle()
.trim(from: 0, to: progress)
.stroke(lineWidth: 3)
.rotationEffect(.degrees(-90))
.foregroundColor(.black)
.frame(width: 50, height: 50)
}
.ignoresSafeArea(.all)
.accessibilityIdentifier("progress")
.onAppear {
DispatchQueue.main.async {
withAnimation(Animation.easeInOut(duration: 1.0).repeatForever(autoreverses: false)) {
progress = 1
}
}
}
}
}