I posted https://developer.apple.com/forums/thread/809481 yesterday about an issue I discovered with pushWindow in visionOS 26.2 RC, but today I discovered a second problem with pushWindow.
If window A calls pushWindow to present window B, and the user pins window B to a wall, the following unexpected behaviors are observed:
Window B spontaneously disappears.
If the user re-launches the (still running) app from the visionOS home view, both window A and window B appear simultaneously. I assume only window B should be visible at this point, since window A pushed window B.
If the user closes window B, it's now impossible to present window B again. Calls to pushWindow appear to be ignored.
If the user force-quits the app and relaunches it, and pushWindow is called again, window B appears, but window A remains visible.
I also noticed this surprising behavior:
This broken state of pushWindow behavior now affects all other apps on the system that may call pushWindow in the future, not just the app whose pushed window was pinned above.
A workaround is to reboot the device, and then the system will behave as expected until the next time the user pins a pushed window.
SwiftUI
RSS for tagProvide views, controls, and layout structures for declaring your app's user interface using SwiftUI.
Posts under SwiftUI tag
200 Posts
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Hi everyone,
I'm currently working on a native macOS app (built with SwiftUI) and I'm trying to implement Password AutoFill functionality so users can use their saved credentials from Keychain or third-party password managers.
I've gone through Apple's documentation, WWDC sessions, and sample code, but I've noticed that the resources primarily focus on iOS and web implementations. There's very limited guidance specifically for macOS.
I've set up:
Associated Domains entitlement with the webcredentials: service
The apple-app-site-association file on my server
TextField with .textContentType(.username) and SecureField with .textContentType(.password)
However, I'm still not seeing the expected AutoFill behavior on macOS like I would on iOS.
Has anyone successfully implemented Password AutoFill on a native macOS app? Are there any macOS-specific considerations or additional steps required that differ from iOS?
Any guidance, sample code, or pointers to documentation I might have missed would be greatly appreciated.
Hi. I have an iOS application with multiple input fields. I have to design an experience such that whenever the user presses enter key on a textfield, it should move focus to the next input field.
Similarly, consider a stack of 3 textfields, I want to cycle the focus as and when the user presses up/down arrow keys.
Other platforms like Android, have this feature out-of-the-box. I wanted to understand if iOS also supports this kind of behavior.
I know how to manually code such UX, but just wanted to confirm whether there is some inherent feature like on android which i can leverage?
Thanks.
I'm using SwiftUI WebView and this error happens when app becomes inactive, the webview changes to blank, and will be in this state all along even if reopen a new webview. When I switch back to WKWebview, everything works fine.
environment Xcode 26.1(17B55) on macOS 15.7.1
Error acquiring assertion: <Error Domain=RBSServiceErrorDomain Code=1 "((target is not running or doesn't have entitlement com.apple.developer.web-browser-engine.rendering AND target is not running or doesn't have entitlement com.apple.developer.web-browser-engine.networking AND target is not running or doesn't have entitlement com.apple.developer.web-browser-engine.webcontent))" UserInfo={NSLocalizedFailureReason=((target is not running or doesn't have entitlement com.apple.developer.web-browser-engine.rendering AND target is not running or doesn't have entitlement com.apple.developer.web-browser-engine.networking AND target is not running or doesn't have entitlement com.apple.developer.web-browser-engine.webcontent))}>
this is the code, pretty simple, in load() function i just call page.load().
WebView(vm.page)
.onAppear {
Task {
await vm.load()
}
}
I am trying the simplest use of attachment in realityKit and get Contextual closure type @MainActor, @Sendable (inout RealityViewCameraContent) async -> void expects 1 argument, but 2 were used in closure body.
Also i get cannot find Attachment in scope
I'm using a custom modifier called AutoSheetDetentModifier to automatically size a sheet based on its content.
On iOS 26, it works as expected: the content height is measured correctly and the sheet shrinks to match that height.
However, on iOS 16, 17 and 18, the same code doesn’t work. The content height is still measured, but the sheet does not reduce its height. Instead, the sheet remains larger and the content appears vertically centered. (Note that content() includes ScrollView)
public struct AutoSheetDetentModifier: ViewModifier {
@State private var height: CGFloat = 380 // default value to avoid bouncing
public func body(content: Content) -> some View {
content
.modifier(MeasureHeightViewModifier(height: $height))
.presentationDetents([.height(height)])
}
}
public struct MeasureHeightViewModifier: ViewModifier {
@Binding var height: CGFloat
public func body(content: Content) -> some View {
content
.fixedSize(horizontal: false, vertical: true)
.background(
GeometryReader { geo -> Color in
DispatchQueue.main.async {
height = geo.size.height
}
return Color.clear
}
)
}
}
extension View {
public func applyAutoSheetDetent() -> some View {
self
.modifier(AutoSheetDetentModifier())
}
}
public var body: some View {
VStack {
header()
content() // includes ScrollView
footer()
}
.background(Color.customGray)
.applyAutoSheetDetent()
}
func content() -> some View {
ScrollView {
VStack {
ForEach(items) { item in
itemRow(item)
}
}
}
.frame(maxHeight: UIScreen.main.bounds.height * 0.7)
}
Screenshot from iOS 26 (working as expected):
Screenshot from iOS 18 (not working):
How can I make .presentationDetents(.height) shrink the sheet correctly on iOS 16–18, the same way it does on iOS 26?
It has been two years since I wrote my a SwiftUI app, and I wanted to start again in Xcode 26. I can no longer see the attributes inspector when I select an element in the canvas. This was an Xcode feature that was very helpful as I am still a novice. Has this feature been deprecated in Xcode 26? And if not, please help explain how I can find and use it.
Topic:
Developer Tools & Services
SubTopic:
Xcode
Tags:
Developer Tools
Interface Builder
Xcode
SwiftUI
Hello!
I’m building my Swift Student Challenge project in Swift Playgrounds, and I’ve run into an issue with app orientation.
Since this is a game, the layout and interactions only work correctly in landscape, but Playgrounds doesn’t offer the usual orientation settings you’d configure in Xcode.
Is there a recommended way to force a landscape-only experience in Swift Playgrounds using SwiftUI? Any workarounds or guidance would be greatly appreciated!
Thank you!
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
Swift Student Challenge
Swift Playground
Playground Support
SwiftUI
I have an iOS and iPadOS app that also runs on macOS Catalyst. The user is able to view their subscription using the SubscriptionStoreView with two SubscriptionOptionGroups.
The documentation does not mention these are supported on macOS Catalyst and the app crashes when attempting to show the SubscriptionStoreView on macOS Catalyst.
If not supported, how can the user manage their subscription on macOS?
Hi everyone!
I've encountered an issue on Mac Catalyst: using the latest inspector modifier causes abnormal Sidebar and Columns state in NavigationSplitView.
Sample Code:
struct ContentView: View {
@State private var isPresented = false
var body: some View {
NavigationSplitView {
List {
ForEach(0..<20, id: \.self) { item in
Text("Item \(item)")
}
}
} content: {
List {
ForEach(0..<20, id: \.self) { item in
Text("Item \(item)")
}
}
} detail: {
List {
}
}
.inspector(isPresented: $isPresented) {
Form {
}
}
}
}
Steps to reproduce:
Xcode 16 beta 7, create a new iOS project
Paste the code above
Enable Mac Catalyst
Run on Mac (macOS 15 beta 9)
Press Command+N three times to open 3 new windows
Click the Sidebar Toggle button
The issue occurs (see screenshot below)
Through testing, I found that as long as the inspector modifier is attached, the issue occurs.
Also, the problem only appears in the 3rd and subsequent newly opened windows—the first two windows work as expected.
FB20061521
Is there a way to display a .icon file in SwiftUI? I want to show the app icon in the app itself but exporting and including the app icon as a PNG feels redundant. This would consume a lot of unnecessary storage especially when including a lot of alternative app icons. There has to be a better way
Otherwise I would file a feedback for that
Thank you
.popover(isPresented: modifier doesn't work on Mac Catalyst when attached to the item in the toolbar. The app crashes on button click, when trying to present the popover.
iOS 26 RC (macOS 26 RC)
Feedback ID - FB20145491
import SwiftUI
struct ContentView: View {
@State private var isPresented: Bool = false
var body: some View {
NavigationStack {
Text("Hello, world!")
.toolbar {
ToolbarItem(placement: .automatic) {
Button(action: {
self.isPresented.toggle()
}) {
Text("Toggle popover")
}
.popover(isPresented: $isPresented) {
Text("Hello, world!")
}
}
}
}
}
}
#Preview {
ContentView()
}
Structs are value types, and the SwiftUI gets reinitialized many times throughout its lifecycle. Whenever it gets reinitialized, would the reference that the delegator has of it still work if the View uses @State or @StateObject that hold a persistent reference to the views data?
protocol MyDelegate: AnyObject {
func didDoSomething()
}
class Delegator {
weak var delegate: MyDelegate?
func trigger() {
delegate?.didDoSomething()
}
}
struct ContentView: View, MyDelegate {
private let delegator = Delegator()
@State counter = 1
var body: some View {
VStack {
Text("\(counter)")
Button("Trigger") {
delegator.trigger()
}
}
}
func didDoSomething() {
counter += 1 //would this call update the counter in the view even if the view's instance is copied over to the delegator?
}
}
I'm trying to add a confirmationDialog to an app, so that the user can select an option from a menu that comes up from the bottom of the screen. This works perfectly for an iOS 18 simulator, but the behavior changes when the simulator is running iOS 26.1.
Is this the intended behavior of .confirmationDialog in iOS 26.1?
We're seeing sporadic crashes on devices running iOS 18.1 - both beta and release builds (22B83). The stack trace is always identical, a snippet of it below. As you can tell from the trace, it's happening in places we embed SwiftUI into UIKit via UIHostingController.
Anyone else seeing this?
4 libobjc.A.dylib 0xbe2c _objc_fatalv(unsigned long long, unsigned long long, char const*, char*) + 30
5 libobjc.A.dylib 0xb040 weak_register_no_lock + 396
6 libobjc.A.dylib 0xac50 objc_storeWeak + 472
7 libswiftCore.dylib 0x43ac34 swift_unknownObjectWeakAssign + 24
8 SwiftUI 0xeb74c8 _UIHostingView.base.getter + 160
9 SwiftUI 0x92124 _UIHostingView.layoutSubviews() + 112
10 SwiftUI 0x47860 @objc _UIHostingView.layoutSubviews() + 36
I’m trying to understand the expected behavior of TabView when using .tabViewStyle(.page) on iPadOS with a hardware keyboard.
When I place a TabView in page mode, swipe gestures correctly move between pages. However, left and right arrow keys do nothing by default, even when the view is made focusable. This feels a bit surprising, since paging with arrow keys seems like a natural keyboard interaction when a keyboard is attached.
Right now, to get arrow-key navigation working, I have to manually:
Make the view focusable
Listen for arrow key presses
Update the selection state manually
This works, but it feels a little tedious for something that seems like it could be built-in.
import SwiftUI
struct PageTabsExample: View {
@State private var selection = 0
private let pageCount = 3
var body: some View {
TabView(selection: $selection) {
Color.red.tag(0)
Color.blue.tag(1)
Color.green.tag(2)
}
.tabViewStyle(.page)
.indexViewStyle(.page)
.focusable(true)
.onKeyPress(.leftArrow) {
guard selection > 0 else { return .ignored }
selection -= 1
return .handled
}
.onKeyPress(.rightArrow) {
guard selection < pageCount - 1 else { return .ignored }
selection += 1
return .handled
}
}
}
My questions:
Is this lack of default keyboard paging for page-style TabView intentional on iPadOS with a hardware keyboard?
Is there a built-in way to enable arrow-key navigation for page-style TabView, or is manual handling the expected approach?
Does my approach above look like the “SwiftUI-correct” way to do this, or is there a better pattern for integrating keyboard navigation with paging?
For this kind of behavior, is it generally recommended to use .onKeyPress like I’m doing here, or would .keyboardShortcut be more appropriate (for example, wiring arrow keys to actions instead)?
Any guidance or clarification would be greatly appreciated. I just want to make sure I’m not missing a simpler or more idiomatic solution.
Thanks!
Looking to see if anyone has experienced this issue, and is aware of any workarounds.
With an app migrating towards SwiftUI Views but still using UIKit for primary navigation, my app makes use of UIHostingController to push SwiftUI Views onto a UINavigationController stack in a lot of areas. With iOS 26, I notice that SwiftUI's Menu view really struggles to present when contained in a UIHostingController. An error is logged to the console on presentation, and depending on the UI, the Menu won't present inside of it's container, or will jump around the screen.
The bug, it seems is based in a private class UIReparentingView and I am curious if anyone has found a work around for this issue. The error reported is:
Adding '_UIReparentingView' as a subview of UIHostingController.view is not supported and may result in a broken view hierarchy. Add your view above UIHostingController.view in a common superview or insert it into your SwiftUI content in a UIViewRepresentable instead.
The simplest way to see this issue is to create a new storyboard based project. From the ViewController present a UIHostingController with a SwiftUI view that has a Menu and then simply tap to open the Menu. Thanks for any input!
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..<20, id: \.self) { index in
if selectedIndex != index {
ContainerRelativeShape() // But what if I want some other corner radius to start with?
.fill(Color(uiColor: .systemGray5))
.matchedGeometryEffect(id: "square-\(index)", in: animation)
.aspectRatio(1, contentMode: .fit)
.padding(.horizontal, 12)
.onTapGesture {
withAnimation() {
selectedIndex = index
}
}
// .containerShape(RoundedRectangle(cornerRadius: 20))
// I can add this to change the corner radius, but this breaks the transition of the corners
} else {
Color.clear
.aspectRatio(1, contentMode: .fit)
.padding(.horizontal, 12)
}
}
}
.padding(.vertical, 16)
}
}
}
}
#Preview {
ContentView()
}
What am I missing here? How can I get this to work? And where is the mistake in my reasoning?
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<Double> = 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?
I see the logo all over the internet, but the only Official logo I can find is the swift logo, the orange one, but the blue one I do not see a place to download it nor the usage guidelines. I have seen it on various Icon site like Icon8. I would like to use it on my reddit forum that is dedicated to SwiftUI but I want to be legal. Is it allowed to use and if so, where can you download the official verison?