Search results for

swiftui

16,583 results found

Post

Replies

Boosts

Views

Activity

In SwiftUI, how to animate from an arbitrary corner radius to the corner radius of the display?
I am trying to implement a common UX/UI pattern: one view with rounded corners transitioning to a view that fills the screen (N.B. having the display's corner radius). I got this to work if both corner radiuses are equal to that of the display (see first GIF). However, I cannot seem to get it to work for arbitrary corner radiuses of the smaller view (i.e., the one that does not fill the screen). I expected the be able to combine ContainerRelativeShape with .containerShape (see code), but this left me with a broken transition animation (see second GIF). import SwiftUI struct ContentView: View { @Namespace private var animation @State private var selectedIndex: Int? var body: some View { ZStack { if let selectedIndex = selectedIndex { ContainerRelativeShape() .fill(Color(uiColor: .systemGray3)) .matchedGeometryEffect(id: square-(selectedIndex), in: animation) .ignoresSafeArea() .onTapGesture { withAnimation() { self.selectedIndex = nil } } .zIndex(1) } ScrollView { VStack(spacing: 16) { ForEach(0..<
1
0
123
Dec ’25
Canvas fails with "Runtime Linking Failure" in Swift Package
I have a view inside a Swift Package that relies on an external Swift Package. My Preview Canvas breaks as soon as I use code from the external package: import ComplexModule // From swift-numerics import SwiftUI struct MyView: View { // Commenting out this line will make Previews work let number: Complex = 123 var body: some View { Text(Hello World) } } #Preview { MyView() } This is part of the error the preview emits: == PREVIEW UPDATE ERROR: GroupRecordingError Error encountered during update group #33 ================================== | [Remote] JITError: Runtime linking failure | | Additional Link Time Errors: | Symbols not found: [ _$sSd10RealModule0A0AAMc, _$s13ComplexModule0A0VMn, _$s13ComplexModule0A0V14integerLiteralACyxG07IntegerD4TypeQz_tcfC ] | | ================================== | | | [Remote] LLVMError | | | | LLVMError: LLVMError(description: Failed to materialize symbols: { (static-MyTarget, { __replacement_tag$1 }) }) Did anyone else see this before?
1
0
115
Dec ’25
SwiftUI Canvas
Hi everyone, I think this is a simple issue. I got the following error message PreviewDevice is ignored in a #Preview macro. Use the device picker at the bottom of the Canvas to change which device type is used for the preview. (from macro 'Preview') after this line: .previewDevice(PreviewDevice(rawValue: iPhone 17 Pro)) But in my Canvas I do not see the device picker. Thank you.
9
0
331
Dec ’25
Compiler exception when using Binding and Swift 6
In my code I use a binding that use 2 methods to get and get a value. There is no problem with swift 5 but when I swift to swift 6 the compiler fails : Here a sample example of code to reproduce the problem : `import SwiftUI struct ContentView: View { @State private var isOn = false var body: some View { VStack { Image(systemName: globe) .imageScale(.large) .foregroundStyle(.tint) Text(Hello, world!) Toggle(change it, isOn: Binding(get: getValue, set: setValue(_:))) } .padding() } private func getValue() -> Bool { isOn } private func setValue(_ value: Bool) { isOn = value } }` Xcode compiler log error : 1. Apple Swift version 6.1.2 (swiftlang-6.1.2.1.2 clang-1700.0.13.5) 2. Compiling with the current language version 3. While evaluating request IRGenRequest(IR Generation for file /Users/xavierrouet/Developer/TestCompilBindingSwift6/TestCompilBindingSwift6/ContentView.swift) 4. While emitting IR SIL function @$sSbScA_pSgIeAghyg_SbIeAghn_TR. for <<debugloc at <compiler-generated>:0:0>
4
0
1.4k
Nov ’25
SwiftUI – How to completely remove the horizontal “ghost lines” inside List with Section and custom rows?
Hi everyone, I’m working on a screen that uses a single SwiftUI List composed of: a top block (statistics, month picker, year selector, total, Entrata/Uscita picker). a list of transactions grouped by day, each group inside its own Section. each row is a fully custom card with rounded corners (RoundedCornerShape) I’m correctly removing all separators using: .listRowSeparator(.hidden) .listSectionSeparator(.hidden) .scrollContentBackground(.hidden) .listStyle(.plain) Each row is rendered like this: TransazioneSwipeRowView(...) .listRowInsets(EdgeInsets(top: 0, leading: 16, bottom: 0, trailing: 16)) .listRowBackground(Color.clear) However, I still see thin horizontal lines appearing between: the search bar and the top block the top block and the start of the list between rows inside the grouped section sometimes at the bottom of a Section These lines are NOT: Divider() system separators backgrounds row borders They seem to be “ghost lines” automatically generated by SwiftUI’s List when multipl
3
0
151
Nov ’25
Reply to SwiftUI – How to completely remove the horizontal “ghost lines” inside List with Section and custom rows?
Thank you! Your explanation about .listRowSeparator(.hidden) being row-specific (and not global to the entire List) was exactly what I needed. I was only applying: .listRowSeparator(.hidden) .listSectionSeparator(.hidden) to the List itself, assuming it would hide all separators automatically — but as you pointed out, SwiftUI requires the modifier to be applied on every row. What I did to fix it I added: .listRowSeparator(.hidden) directly to each transaction row inside my custom content view: ForEach(...) { ... } .listRowSeparator(.hidden) Then I also added it to: the header Section for each day the top block inside ReportMensileView (statistics + month picker + total + picker) This ensured that every row rendered by the List has the separator explicitly hidden. Result All the “mysterious horizontal lines” immediately disappeared, without breaking: native List scrolling swipe-to-delete custom rounded card backgrounds grouped Sections Everything now renders perfectly clean. Thanks again for pointing
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’25
AVCapturePhotoOutput crashes at delegate callback on MacOS 13.7.5
A functioning Multiplatform app, which includes use of Continuity Camera on an M1MacMini running Sequoia 15.5, works correctly capturing photos with AVCapturePhoto. However, that app (and a test app just for Continuity Camera) crashes at delegate callback when run on a 2017 MacBookPro under MacOS 13.7.5. The app was created with Xcode 16 (various releases) and using Swift 6 (but tried with 5). Compiling and running the test app with Xcode 15.2 on the 13.7.5 machine also crashes at delegate callback. The iPhone 15 Continuity Camera gets detected and set up correctly, and preview video works correctly. It's when the CapturePhoto code is run that the crash occurs. The relevant capture code is: func capturePhoto() { let captureSettings = AVCapturePhotoSettings() captureSettings.flashMode = .auto photoOutput.maxPhotoQualityPrioritization = .quality photoOutput.capturePhoto(with: captureSettings, delegate: PhotoDelegate.shared) print(**** CameraManager: capturePhoto) } and the delegate callbacks are: class PhotoDel
1
0
463
Nov ’25
What's the best way to support Genmoji with SwiftUI?
I want to support Genmoji input in my SwiftUI TextField or TextEditor, but looking around, it seems there's no SwiftUI only way to do it? If none, it's kind of disappointing that they're saying SwiftUI is the path forward, but not updating it with support for new technologies. Going back, does this mean we can only support Genmoji through UITextField and UIViewRepresentable? or there more direct options? Btw, I'm also using SwiftData for storage.
1
0
734
Nov ’25
App mysteriously crashing in CFNetwork.LoaderQ queue
I’m stuck with repeated production crashes in my SwiftUI app and I can’t make sense of the traces on my own. The symbolicated reports show the same pattern: Crash on com.apple.CFNetwork.LoaderQ with EXC_BAD_ACCESS / PAC failure Always deep in CFNetwork, most often in URLConnectionLoader::loadWithWhatToDo(NSURLRequest*, _CFCachedURLResponse const*, long, URLConnectionLoader::WhatToDo) No frames from my code, no sign of AuthManager or tokens. What I’ve tried: Enabled Address Sanitizer, Malloc Scribble, Guard Malloc, Zombies. Set CFNETWORK_DIAGNOSTICS=3 and collected Console logs. Stress-tested the app (rapid typing, filter switching, background/foreground, poor network with Network Link Conditioner). Could not reproduce the crash locally. So far: Logs show unrelated performance faults (I/O on main thread, CLLocationManager delegate), but no obvious CFNetwork misuse. My suspicion is a URLSession lifetime or delegate/auth-challenge race, but I can’t confirm because I can’t trigger it. Since starting this
6
0
4k
Nov ’25
ZoneSharing CloudKit UI
I am trying to use Zone Sharing in my SwiftUI app. I have been attempting to get the UICloudSharingController to show an initial share screen to pick users and the mechanism to send the invitation. From the documentation, it appears that the UICloudSharingController .init(preparationHandler:) API is deprecated so I am not using that approach. Following the Apple documentation, I am creating a Zone Share and NOT saving it and presenting using the UICloudSharingController(share:container:) API. However, this presents a UI that is the 'mgmt' API for a Share. I can get to the UI I was expecting by tapping on the 'Share with More People' option, but I want to start on that screen for the user when they have not shared this before. So, I found an example app from Apple at: https://github.com/apple/sample-cloudkit-zonesharing. It has the same behavior. So we can simply discuss this problem based on that example code. How do I get the next View presented when tapping 'Share Group' to be the invitation for ne
4
0
308
Nov ’25
SwiftUI List insertion changes aren't animated on macOS 15
I've been struggling with this issue since the release of macOS 15 Sequoia. I'm wondering if anyone else has encountered it or if anyone has a workaround to fix it. Inserting a new element into the array that acts as data source for a SwiftUI List with a ForEach is never animated even if the insertion is wrapped in a withAnimation() call. It seems that some other changes can be automated though: e.g. calls to shuffle() on the array successfully animate the changes. This used to work fine on macOS 14, but stopped working on macOS 15. I created a very simple project to reproduce the issue: import SwiftUI @main struct TestApp: App { var body: some Scene { WindowGroup { ContentView() } } } struct IdentifiableItem: Identifiable { let id = UUID() var name: String { Item (id) } } struct ContentView: View { @State var items: [IdentifiableItem] = [ IdentifiableItem(), IdentifiableItem(), IdentifiableItem(), IdentifiableItem(), IdentifiableItem(), IdentifiableItem(), IdentifiableItem(), IdentifiableIt
3
0
639
Nov ’25
Scrolling through long lists with ScrollView and LazyVstack
What is the correct way to implement scrolling in a looong list that uses ScrollView and LazyVstack Imagine I have some api that returns a longs list of comments with replies The basic usecase is to scroll to the bottom(to the last comment) Most of the time this works fine But, imagine some of the comments have many replies like 35 or more (or even 300) User expands replies for the first post, then presses scroll to bottom. The scrollbar reaches the bottom and I see the blank screen. Sometimes the scrollbar may jump for a while before lazyvstack finishes loading or until I manually scroll up a bit or all the way up and down What should I do in this case? Is this the swiftui performance problem that has no cure? Abstract example: ScrollViewReader { proxy in ScrollView { LazyVStack { ForEach(comments) { comment in CommentView(comment: comment) .id(comment-(comment.id)) } } } } struct CommentView: View { let comment: Comment @State var isExpanded = false var body: some View { VStack { Text(comment.text)
5
0
304
Nov ’25
Reply to WidgetKit with Data from CoreData
A solution is not to rely on a Data Manager class and its associates but to use UserDefaults so that Widget's getTimeline method will be called when ContentView submits data to it. By this approach, you can update Widget's View. import SwiftUI import WidgetKit struct ContentView: View { var body: some View { VStack { Button { let task0 = TaskItem(id: UUID(), name: Dish washing, isComplete: false, dueDate: Date.now.addingTimeInterval(86400)) let task1 = TaskItem(id: UUID(), name: Bed making, isComplete: false, dueDate: Date.now.addingTimeInterval(86400 * 2)) saveTasksToWidget(tasks: [task0, task1]) } label: { Image(systemName: globe) .imageScale(.large) } .tint(.pink) .buttonStyle(.borderedProminent) } .padding() } private func saveTasksToWidget(tasks: [TaskItem]) { guard let sharedDefaults = UserDefaults(suiteName: group.abc) else { print(Failed to get shared UserDefaults.) return } do { let encoder = JSONEncoder() let encodedData = try encoder.encode(tasks) sharedDefaults.set(encodedData, forKey: wi
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’25
WidgetKit with Data from CoreData
I have a SwiftUI app. It fetches records through CoreData. And I want to show some records on a widget. I understand that I need to use AppGroup to share data between an app and its associated widget. import Foundation import CoreData import CloudKit class DataManager { static let instance = DataManager() let container: NSPersistentContainer let context: NSManagedObjectContext init() { container = NSPersistentCloudKitContainer(name: DataMama) container.persistentStoreDescriptions = [NSPersistentStoreDescription(url: FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: group identifier)!.appendingPathComponent(Trash.sqlite))] container.loadPersistentStores(completionHandler: { (description, error) in if let error = error as NSError? { print(Unresolved error (error), (error.userInfo)) } }) context = container.viewContext context.automaticallyMergesChangesFromParent = true context.mergePolicy = NSMergePolicy(merge: .mergeByPropertyObjectTrumpMergePolicyType) } func save() { do { try c
7
0
273
Nov ’25