When building with iOS 26 SDK beta 5 (23A5308f), onTapGesture is no longer being triggered on Map views. This appears to be a regression in beta 5 specifically, as this issue was not present in beta 4. How to reproduce Code The following code demonstrates the issue, as seen in the videos below. import MapKit import SwiftUI struct ContentView: View { @State private var location = CGPoint.zero var body: some View { Map() .onTapGesture { location in self.location = location } .safeAreaInset(edge: .bottom) { VStack(alignment: .center) { Text(iOS (UIDevice.current.systemVersion)) .font(.largeTitle) Text(Tapped Location) Text((location.x), (location.y)) } .frame(maxWidth: .infinity, alignment: .center) .background(.background) } } } Demo The gifs below show the behavior in iOS 18.5 (in which the tap gestures are recognized and tapped coordinate is displayed in the safe area inset) and iOS 26 beta 5 (in which the tap gestures have no effect): iOS 18 iOS 26 Next steps? Is there a recommended workaround for t
Search results for
swiftui
16,633 results found
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I reproduced this in iPhone 17 and iPhone 17 Pro simulators running iOS 26.0 import SwiftUI struct ContentView: View { var body: some View { NavigationStack { ScrollView { VStack { ForEach(0..<100) { i in Text(Row (i)) .frame(maxWidth: .infinity) } } .padding() } .navigationTitle(Toolbar Test) .navigationBarTitleDisplayMode(.inline) // or .automatic } } } Run this code in a vanilla SwiftUI app. Toggle the appearance to dark mode. In the simulator's Settings app -> Accessibility -> Display and Text Size. Turn ON Reduce Transparency. Go back to the app and start scrolling if you need to. You can observe that the title is unreadable - black text on a black navigation bar.
I came across the same bug: When in .dark mode AND reduced transparency, OS picks in the assets the Any Luminosity variant instead of the dark one for the inline title (not the large title). I have a Color with 4 variants: light/dark x normal/high-contrast. I apply it to navigationTitle with a UIKit function: .onAppear { setTitleMyColor(.text) } // apply TextColor from the assets And I used the following workaround in this UIKit function: import UIKit import SwiftUI /// A function relying on UIKit to force the navigation title color @MainActor func setTitleUIColor(_ color:UIColor) { // iOS bug workAround: if reducedTransparency and dark mode are both enabled, // For the inline title only (not the largeTitle) // iOS picks in the assets the Any Luminosity variant instead of the dark one let colorFixed = UIAccessibility.isReduceTransparencyEnabled ? .systemGray: color let appearance = UINavigationBarAppearance() appearance.titleTextAttributes = [.foregroundColor: colorFixed] appearance.largeTitleTextAtt
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
The exact same problem is also triggered through SwiftUI's ColorPicker(), when supportsOpacity is set to false. As with the original post, the issue is with macOS 26.0 and Xcode 26.0.1 when building a macOS app.
Topic:
UI Frameworks
SubTopic:
AppKit
After a bunch of more digging around, I am finally getting a little traction on how to create a SwiftUI interface. And I am posting this here in hopes of helping someone else in my position. struct MyCustomView: View { @State private var volume: Double = 0 var body: some View { Group { HStack { Text(oo) .padding(2) .border(Color.black) Button(Stop) { } Button(Play) { } Button(Jump) { } } .padding(.top, 10) VStack { Slider(value: $volume, in: -10...100) .offset(x: 13,y: 0) .frame(width: 150, height: 40) } } .offset(x: -150, y: 0) } } I did a screenshot of a portion of the original music player controls and the same thing using SwiftUI. Now there is the basis for improving the SwiftUI code to better match that of the original screen. I hope this helps someone else.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
Thank you for the post and the images as well as the code snippet. The background color is different but tint appear to remain unchanged. Could you please provide additional information regarding the Xcode version you are using to encounter this issue? Additionally, it seems that you are utilizing Catalyst. Could you also share the SwiftUI code that generates this issue, including all relevant version information, so that I can reproduce it? If so, please share a link to your test project. That'll help us better understand what's going on. If you're not familiar with preparing a test project, take a look at Creating a test project. Albert Pascual
Worldwide Developer Relations.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
On macOS Tahoe 26, NSSplitViewController introduced the NSSplitViewItemAccessoryViewController and related-APIs in NSSplitViewController, such as addBottomAlignedAccessoryViewController(_:). Those APIs allow you to place accessory views at the top and bottom of a split view with a nice edge effect. I understand how to use them with AppKit. However, I’m not sure how to achieve the same functionality with SwiftUI.
Environment iOS 26 (23A343) Xcode 26 Reproduces on device and Simulator Description When presenting a SwiftUI WebView (native iOS 26 component) or a WKWebView/UIWebView via UIViewRepresentable, focusing a text field inside the web view and then dismissing it breaks the keyboard layout behavior. After returning to the main app, tapping any TextField causes the keyboard to cover bottom controls (e.g. buttons). Expected safe area insets are not applied. The issue is only resolved after closing and reopening the keyboard once. Steps to Reproduce Open a SwiftUI screen with WebView (via .sheet or NavigationLink). Inside the web view, tap a text field to show the keyboard. Dismiss the web view. Tap a TextField in the main app. Expected Result Layout should adjust correctly. Bottom controls stay visible above the keyboard. Actual Result Keyboard covers bottom controls. Insets are ignored until the keyboard is dismissed and reopened. Notes Reproduces with: Native SwiftUI WebView (iOS 26) WKW
I tried playing with SF Symbols variable value draw from the first iOS 26 beta and it has never been working, whereas the SwiftUI version works properly. I just copied and pasted the code from the related video What’s new in SF Symbols 7 and it simply doesn't work (screenshot attached). Full view controller code is at the end of the post. imageView.image = UIImage(systemName: thermometer.high, variableValue: 0.5) imageView.preferredSymbolConfiguration = UIImage.SymbolConfiguration(variableValueMode: .draw) Am I missing something? Or is it still not ready? I reproduced the issue with Xcode 26 beta 6 (17A5305f). The release candidates are approaching fast and I am worried this will not be working by then. The feedback ID is FB18898182. class ViewController: UIViewController { let imageView = UIImageView() override func viewDidLoad() { super.viewDidLoad() imageView.image = UIImage(systemName: thermometer.high, variableValue: 0.5) imageView.preferredSymbolConfiguration = UIImage.SymbolConfiguration(varia
Developing a prototype Vision Pro app and would like to render a 3D scene made from Reality Composer Pro on an image anchor in a RealityView. But I have no luck so far to make it work and need some guidance to move on. I got the image file stored in the assets like below: And from below is the source codes: import SwiftUI import RealityKit import RealityKitContent struct AnchorView: View { @State var imageEntity: Entity = { let anchorEntity = AnchorEntity(.image(group: AR Resources, name: reanchor)) return anchorEntity }() var body: some View { RealityView { content in do { // Add the initial RealityKit content if let scene = try? await Entity(named: Scene, in: realityKitContentBundle) { imageEntity.addChild(scene) content.add(imageEntity) } } catch { print(Error occurs when adding reality view content: (error)) } } } }
Thanks to the responses above, as I appreciate the feedback. After more digging, I may have found more information about how SwiftUI works. It seems that View is an integral part of how Swift places controls on Forms. At the time I thought that the keyword View was used to differentiate between Controls on the Form, but this does seem to be the case as seen below. I found an example in the book from Paul Hudson, Hacking With MacOS, Chapter 13. There, Paul has as example with a series of controls appearing on the right side of a Form, which project down the right side, top to bottom. The skeleton sample code that creates this display is shown below. var body: some View { HStack(spacing: 20) { RenderView(document: document) .draggable(snapshotToURL()) .dropDestination(for: URL.self) { items, location in handleDrop(of: items)} VStack(spacing: 20) { VStack(alignment: .leading) { // stuff here } VStack(alignment: .leading) { // stuff here } .labelsHidden() VStack(alignment: .leading) { // stuff here } } .
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
Hi community: I noticed that each closure is counted as lines in code coverage (unit tests) (Xcode 14.1.0) in a swiftUI File. I mean, If you coded and VStack that involves another HStack, and HStack contains 4 lines, and the VStack contains 6 lines counting the HStack. The total executable lines should be 6 (6 lines in the file). But Xcode count 10, counting twice the HStack lines. Is it a bug, or is it correct? You know, I don't know if Apple has another concept about executable lines. Also, Is it possible to remove previews with any configuration from code coverage or constant files? Thanks for all.
I'm seeing the exact same thing, and I can't believe that this post is the only thing I can find online about it! I have one view that's 183 lines, including comments and empty lines, but without the #Preview, and the code coverage table shows that it has 624 lines. It's bad enough that it's well nigh impossible to unit-test SwiftUI views, but wildly inflating their line counts is causing our overall test coverage numbers to be much lower than they should be. (I've confirmed this in Xcode 16.4 and 26.0.1.)
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
Hi, I want to follow the SwiftUI tutorials from Apple Developer. After creating the “Landmarks” app and clicking on ContentView, the preview shows: Cannot preview in this file Failed to launch net.bayerthomas.Landmarks with the Diagnostics: == PREVIEW UPDATE ERROR: FailedToLaunchAppError: Failed to launch net.bayerthomas.Landmarks ================================== | [Remote] JITError | | ================================== | | | [Remote] CouldNotLoadInputObjectFile: Could not load object file during preview: /Users/thomas/Library/Developer/Xcode/DerivedData/Landmarks-gpfsfizlhntsahandeumxmhwbjfj/Build/Intermediates.noindex/Landmarks.build/Debug-iphonesimulator/Landmarks.build/Objects-normal/arm64/ContentView.1.preview-thunk-launch.o | | | | path: /Users/thomas/Library/Developer/Xcode/DerivedData/Landmarks-gpfsfizlhntsahandeumxmhwbjfj/Build/Intermediates.noindex/Landmarks.build/Debug-iphonesimulator/Landmarks.build/Objects-normal/arm64/ContentView.1.preview-thunk-launch.o | | | | =====================
Topic:
UI Frameworks
SubTopic:
SwiftUI
I am working on a SwiftUI project using Core Data. I have an entity called AppleUser in my data model, with the following attributes: id (UUID), name (String), email (String), password (String), and createdAt (Date). All attributes are non-optional. I created the corresponding Core Data class files (AppleUser+CoreDataClass.swift and AppleUser+CoreDataProperties.swift) using Xcode’s automatic generation. I also have a PersistenceController that initializes the NSPersistentContainer with the model name JobLinkModel. When I try to save a new AppleUser object using: let user = AppleUser(context: viewContext) user.id = UUID() user.name = User1 user.email = ... user.password = password1 user.createdAt = Date()【The email is correctly formatted, but it has been replaced with “…” for privacy reasons】 try? viewContext.save() I get the following error in the console:Core Data save failed: Foundation._GenericObjCError.nilError, [:] User snapshot: [id: ..., name: User1, email: ..., password: ..., createdAt: ...]