Search results for

“swiftui”

17,235 results found

Post

Replies

Boosts

Views

Activity

Reply to Can I disable a SwiftUI View from being a draggable source, but still leave it enabled as a dropDestination?
Sorry for the delay, I didn't get the notification. Thanks for the code, I would recommend to add a link to a focused project where I can download and play with it as of course without the images nor drop targets is hard to see what you are trying to accomplish and will help many developers here figure it out. Customize the drag preview to make the interaction more intuitive. You can modify the draggable modifier .draggable(player, preview: { VStack { Image(jersey) .resizable() .frame(width: 50, height: 50) if let player = content.player { Text(player.last) .font(.caption) } } }) Currently, the drop handler just prints the item. You might want to update the CellContent's player based on the drop? .dropDestination(for: String.self) { items, location in if let firstItem = items.first { print(Dropped: (firstItem)) // Update player logic here if needed // e.g., content.player = updatedPlayerBasedOn(firstItem) } return true } Looking forward to your focused sample. That'll help us better understand what's going on
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’26
MusicKit + AirPlay
Hello, I'm working on a MusicKit based SwiftUI app. I've integrated AirPlay using the AVRoutePickerView like so: struct UIKitAirPlayPickerView: UIViewRepresentable { func makeUIView(context: Context) -> AVRoutePickerView { let routePickerView = AVRoutePickerView() routePickerView.prioritizesVideoDevices = false return routePickerView } func updateUIView(_ uiView: AVRoutePickerView, context: Context) {} } The AirPlay menu appears as expected, and selecting an AirPlay device functions as expected. I'm currently sending audio from my app to a HomePod. However, the state of the AVRoutePickerView does not reflect the playback state. There is no cover art and it says Not Playing. When my device is locked, my lock screen shows the album art, metadata and AirPlay routing as expected. My app uses the ApplicationMusicPlayer however I encounter the same behavior using the SystemMusicPlayer. Any guidance on how to troubleshoot this? Is there any other way to integrate the system AirPlay picker into my app, or
1
0
573
Feb ’26
Help with visionOS pushWindow issues requested
I first started using the SwiftUI pushWindow API in visionOS 26.2, and I've reported several bugs I discovered, listed below. Under certain circumstances, pushed window relationships may break, and this behavior affects all other apps, not just the app that caused the problem, until the next device reboot. In other cases, the system may crash and restart. (FB21287011) When a window presented with pushWindow is dismissed, its parent window reappears in the wrong location (FB21294645) Pinning a pushed window to a wall breaks pushWindow for all other apps on the system (FB21594646) pushWindow interacts poorly with the window bar close app option (FB21652261) If a window locked to a wall calls pushWindow, the original window becomes unlocked (FB21652271) If a window locked in place calls pushWindow and the pushed window is closed, the system freezes (FB21828413) pushWindow, UIApplication.open, and a dismissed immersive space result in multiple failures that require a device reboot (FB21840747) visionOS r
2
0
1.4k
Feb ’26
Severe Frame Drops When Resizing macOS Window with Dynamic LazyVGrid
Context: I am building a macOS file (currently image only) browser using SwiftUI. The core view is a ScrollView containing a LazyVGrid. The layout is dynamic: as the window resizes, I calculate the optimal number of columns and spacing using a GeometryReader. The Issue: While scrolling is pretty smooth (thanks to custom image caching and prefetching), window resizing is significantly laggy. After having scrolled the UI stutters and drops frames heavily while dragging the window edge. The Code: https://github.com/MorusPatre/Binder
2
0
144
Feb ’26
Reply to SwiftUI can not find
Hi, The problems you are facing is due to the fact that you named your project SwiftUI. This is causing the build system to create a module for your app called SwiftUI which is the exact same module name that the system library is called. I expect you'd see these issues resolved if you rename your app to something that doesn't match one of the system frameworks.
Feb ’26
Reply to Launchscreen issues on iPadOS 26
I can confirm there is something crashing my Apps that only have Launchscreen storyboards. I use Autoresizing and not Autolayout. And guys please, make a real effort to build a Launchscreen component in SwiftUI. It makes no sense in 2026, always ten years after and we still have a storyboard file messing/crashing our Apps in Swift.
Topic: UI Frameworks SubTopic: General
Feb ’26
WidgetKit (systemMedium) SwiftUI Text: auto-fit to the largest font size without “…”
Hi all, I’m stuck on a WidgetKit/SwiftUI layout issue. I have a systemMedium widget that shows a block of text. What I want is simple: The text should be as large as possible But it must always fully fit inside the widget No ellipsis (“…”) Short text → big font Longer text → shrink only as much as needed The problem: when I try to make the font larger, the widget often shows only a couple of words and then “…” (or it looks like it’s truncating/clipping), even though I’m using multiline text (lineLimit(nil) etc.). If I keep a small fixed font size, the entire text shows fine — so the input string isn’t truncated. I tried a few approaches: ViewThatFits seeing which font size fits minimumScaleFactor Measuring with NSAttributedString.boundingRect + binary search to calculate the biggest font size that should fit But WidgetKit still behaves inconsistently and I can’t get a reliable “largest size that fits” result. Is there a recommended, production-safe way to do this in WidgetKit? Also: can a SwiftUI
0
0
275
Feb ’26
SWİFT STUDENT CHALLANGE iOS vers
I am currently developing my submission for the Swift Student Challenge 2026. My project focuses on financial literacy for children (Canteen Hero), and I want to ensure it runs flawlessly during the judging process. I have two specific questions regarding the environment: Which iOS/iPadOS version do judges typically use for testing? Should I assume they will be using the latest stable release (e.g., iOS 19/iPadOS 19) or a specific beta version? Device Compatibility: Is it a requirement to design the app for all previous iOS versions (backward compatibility), or is it acceptable to target only the latest APIs (iOS 18/19+) to utilize modern features like SwiftData and the latest SwiftUI animations? Thank you for your guidance!
1
0
448
Feb ’26
Cannot preview in Xcode
My computer setup is I work from an account with regular (non-admin) privileges. I login into the admin account to install apps, update the OS, that kind of stuff, but work is from the reduced privileges account. And, when in it, I cannot preview swiftUI views in Xcode. Incredibly frustrating, have tried everything including a complete wipeout of the disk and reinstall, but no luck. Don't have any iOS simulator targets installed, it's macOS target I am working on. If I fire up xcode from the admin account it's all good, previes work and so on. Not so in the non-admin account, consistenly getting the Cannot preview in this file. Failed to launch xxxx Also tried elevating the privileges of the account to Admin, rebooting, no luck. Tried creating a new account, non-admin or admin, no luck. The detailed error repeats something along the lines of: == PREVIEW UPDATE ERROR: GroupRecordingError Error encountered during update group #3 ================================== | FailedToLaunchAppError: Failed to lau
0
0
206
Feb ’26
SwiftUI mysterious behavior
Hello dear developers! Recently, I stumbled upon some really strange behavior of SwiftUI and I’m very curious why it works this way struct ContentView: View { @State private var title: String? @State private var isSheetPresented: Bool = false var body: some View { Button(Hello, world!) { title = Sheet title isSheetPresented = true } .sheet(isPresented: $isSheetPresented, content: { if let title { Text(title) } else { EmptyView() } }) } } Why in this case when we tap the button and sheet comes in we go to the branch else even though we set title before isSheetPresented but it still somehow nil But what really drive me crazy is that if we change a little bit code to this: I just added another @State property 'number' and use it as the Button's title. In this scenario it works 😃 and Text in the sheet view appearing struct ContentView: View { @State private var title: String? @State private var number = 0 @State private var isSheetPresented = false var body: some View { Button((number)) { title = Sheet
2
0
156
Feb ’26
WebView on macOS
Hello everyone, I am currently working on integrating a WebView into my macOS application, intended to allow users to browse tutorial webpages directly within the app. Although I’ve followed an example that appears syntactically correct, the WebView does not render any webpage content. Below is a code snippet for reference: import SwiftUI import WebKit struct HelpWebView: View { @State private var toggle = false @State private var page = WebPage() private var url: URL { toggle ? URL(string: https://www.webkit.org)! : URL(string: https://www.swift.org)! } var body: some View { WebView(page) .onAppear { page.load(URLRequest(url: url)) } .onChange(of: toggle) { page.load(URLRequest(url: url)) } .toolbar { Button(Reload, systemImage: arrow.clockwise) { toggle.toggle() } } } } I would greatly appreciate any insights or suggestions on what might be causing this issue or how to resolve it. Thank you in advance for your help!
Topic: Safari & Web SubTopic: General Tags:
1
0
284
Feb ’26
WebView on macOS
Hello everyone, I am currently working on integrating a WebView into my macOS application, intended to allow users to browse tutorial webpages directly within the app. Although I’ve followed an example that appears syntactically correct, the WebView does not render any webpage content. Below is a code snippet for reference: import SwiftUI import WebKit struct HelpWebView: View { @State private var toggle = false @State private var page = WebPage() private var url: URL { toggle ? URL(string: https://www.webkit.org)! : URL(string: https://www.swift.org)! } var body: some View { WebView(page) .onAppear { page.load(URLRequest(url: url)) } .onChange(of: toggle) { page.load(URLRequest(url: url)) } .toolbar { Button(Reload, systemImage: arrow.clockwise) { toggle.toggle() } } } } I would greatly appreciate any insights or suggestions on what might be causing this issue or how to resolve it. Thank you in advance for your help!
Topic: Safari & Web SubTopic: General Tags:
1
0
417
Feb ’26
Reply to Annoying popup window in Xcode Previews when the initial controller of the main storyboard is a macOS window
Thank you for replying, Albert. I'm focusing on developing a macOS app using non-SwiftUI app lifecycle. I would need some SwiftUI-AppKit bridging in this project, and I might want to use Xcode Previews also on AppKit view controllers. I'm encountering the problem described in the first post, meaning that I can't experience both Xcode Previews and Storyboard well as expected. That popup window can be moved away, but it reappears back at the initial position every time I write source code. I created the first post a bit prematurely. Sorry for that. I noticed that it's nothing about the entry point. Instead, it's about making any instance of window controller from storyboards — instantiateInitialController() I used before, and other instantiate… methods. Just make a window controller from a storyboard and show its window (e.g. in applicationDidFinishLaunching(_:)). Only NSStoryboard trigger the problem, while NSNib don't. I also noticed that the mechanism behind the problem also works when the
Feb ’26
Reply to Can I disable a SwiftUI View from being a draggable source, but still leave it enabled as a dropDestination?
Sorry for the delay, I didn't get the notification. Thanks for the code, I would recommend to add a link to a focused project where I can download and play with it as of course without the images nor drop targets is hard to see what you are trying to accomplish and will help many developers here figure it out. Customize the drag preview to make the interaction more intuitive. You can modify the draggable modifier .draggable(player, preview: { VStack { Image(jersey) .resizable() .frame(width: 50, height: 50) if let player = content.player { Text(player.last) .font(.caption) } } }) Currently, the drop handler just prints the item. You might want to update the CellContent's player based on the drop? .dropDestination(for: String.self) { items, location in if let firstItem = items.first { print(Dropped: (firstItem)) // Update player logic here if needed // e.g., content.player = updatedPlayerBasedOn(firstItem) } return true } Looking forward to your focused sample. That'll help us better understand what's going on
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Feb ’26
MusicKit + AirPlay
Hello, I'm working on a MusicKit based SwiftUI app. I've integrated AirPlay using the AVRoutePickerView like so: struct UIKitAirPlayPickerView: UIViewRepresentable { func makeUIView(context: Context) -> AVRoutePickerView { let routePickerView = AVRoutePickerView() routePickerView.prioritizesVideoDevices = false return routePickerView } func updateUIView(_ uiView: AVRoutePickerView, context: Context) {} } The AirPlay menu appears as expected, and selecting an AirPlay device functions as expected. I'm currently sending audio from my app to a HomePod. However, the state of the AVRoutePickerView does not reflect the playback state. There is no cover art and it says Not Playing. When my device is locked, my lock screen shows the album art, metadata and AirPlay routing as expected. My app uses the ApplicationMusicPlayer however I encounter the same behavior using the SystemMusicPlayer. Any guidance on how to troubleshoot this? Is there any other way to integrate the system AirPlay picker into my app, or
Replies
1
Boosts
0
Views
573
Activity
Feb ’26
Help with visionOS pushWindow issues requested
I first started using the SwiftUI pushWindow API in visionOS 26.2, and I've reported several bugs I discovered, listed below. Under certain circumstances, pushed window relationships may break, and this behavior affects all other apps, not just the app that caused the problem, until the next device reboot. In other cases, the system may crash and restart. (FB21287011) When a window presented with pushWindow is dismissed, its parent window reappears in the wrong location (FB21294645) Pinning a pushed window to a wall breaks pushWindow for all other apps on the system (FB21594646) pushWindow interacts poorly with the window bar close app option (FB21652261) If a window locked to a wall calls pushWindow, the original window becomes unlocked (FB21652271) If a window locked in place calls pushWindow and the pushed window is closed, the system freezes (FB21828413) pushWindow, UIApplication.open, and a dismissed immersive space result in multiple failures that require a device reboot (FB21840747) visionOS r
Replies
2
Boosts
0
Views
1.4k
Activity
Feb ’26
Severe Frame Drops When Resizing macOS Window with Dynamic LazyVGrid
Context: I am building a macOS file (currently image only) browser using SwiftUI. The core view is a ScrollView containing a LazyVGrid. The layout is dynamic: as the window resizes, I calculate the optimal number of columns and spacing using a GeometryReader. The Issue: While scrolling is pretty smooth (thanks to custom image caching and prefetching), window resizing is significantly laggy. After having scrolled the UI stutters and drops frames heavily while dragging the window edge. The Code: https://github.com/MorusPatre/Binder
Replies
2
Boosts
0
Views
144
Activity
Feb ’26
Reply to SwiftUI can not find
Hi, The problems you are facing is due to the fact that you named your project SwiftUI. This is causing the build system to create a module for your app called SwiftUI which is the exact same module name that the system library is called. I expect you'd see these issues resolved if you rename your app to something that doesn't match one of the system frameworks.
Replies
Boosts
Views
Activity
Feb ’26
Reply to Launchscreen issues on iPadOS 26
I can confirm there is something crashing my Apps that only have Launchscreen storyboards. I use Autoresizing and not Autolayout. And guys please, make a real effort to build a Launchscreen component in SwiftUI. It makes no sense in 2026, always ten years after and we still have a storyboard file messing/crashing our Apps in Swift.
Topic: UI Frameworks SubTopic: General
Replies
Boosts
Views
Activity
Feb ’26
Reply to Changing focus state in onSubmit causes keyboard to bounce
Does anyone know if Apple has plans to fix this issue? We are facing this issue in our SwiftUI forms as well, and trying to work around it introduces fiddly issues with inter-op between UIKit and SwiftUI input fields requiring focus.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Feb ’26
WidgetKit (systemMedium) SwiftUI Text: auto-fit to the largest font size without “…”
Hi all, I’m stuck on a WidgetKit/SwiftUI layout issue. I have a systemMedium widget that shows a block of text. What I want is simple: The text should be as large as possible But it must always fully fit inside the widget No ellipsis (“…”) Short text → big font Longer text → shrink only as much as needed The problem: when I try to make the font larger, the widget often shows only a couple of words and then “…” (or it looks like it’s truncating/clipping), even though I’m using multiline text (lineLimit(nil) etc.). If I keep a small fixed font size, the entire text shows fine — so the input string isn’t truncated. I tried a few approaches: ViewThatFits seeing which font size fits minimumScaleFactor Measuring with NSAttributedString.boundingRect + binary search to calculate the biggest font size that should fit But WidgetKit still behaves inconsistently and I can’t get a reliable “largest size that fits” result. Is there a recommended, production-safe way to do this in WidgetKit? Also: can a SwiftUI
Replies
0
Boosts
0
Views
275
Activity
Feb ’26
SWİFT STUDENT CHALLANGE iOS vers
I am currently developing my submission for the Swift Student Challenge 2026. My project focuses on financial literacy for children (Canteen Hero), and I want to ensure it runs flawlessly during the judging process. I have two specific questions regarding the environment: Which iOS/iPadOS version do judges typically use for testing? Should I assume they will be using the latest stable release (e.g., iOS 19/iPadOS 19) or a specific beta version? Device Compatibility: Is it a requirement to design the app for all previous iOS versions (backward compatibility), or is it acceptable to target only the latest APIs (iOS 18/19+) to utilize modern features like SwiftData and the latest SwiftUI animations? Thank you for your guidance!
Replies
1
Boosts
0
Views
448
Activity
Feb ’26
Cannot preview in Xcode
My computer setup is I work from an account with regular (non-admin) privileges. I login into the admin account to install apps, update the OS, that kind of stuff, but work is from the reduced privileges account. And, when in it, I cannot preview swiftUI views in Xcode. Incredibly frustrating, have tried everything including a complete wipeout of the disk and reinstall, but no luck. Don't have any iOS simulator targets installed, it's macOS target I am working on. If I fire up xcode from the admin account it's all good, previes work and so on. Not so in the non-admin account, consistenly getting the Cannot preview in this file. Failed to launch xxxx Also tried elevating the privileges of the account to Admin, rebooting, no luck. Tried creating a new account, non-admin or admin, no luck. The detailed error repeats something along the lines of: == PREVIEW UPDATE ERROR: GroupRecordingError Error encountered during update group #3 ================================== | FailedToLaunchAppError: Failed to lau
Replies
0
Boosts
0
Views
206
Activity
Feb ’26
SwiftUI mysterious behavior
Hello dear developers! Recently, I stumbled upon some really strange behavior of SwiftUI and I’m very curious why it works this way struct ContentView: View { @State private var title: String? @State private var isSheetPresented: Bool = false var body: some View { Button(Hello, world!) { title = Sheet title isSheetPresented = true } .sheet(isPresented: $isSheetPresented, content: { if let title { Text(title) } else { EmptyView() } }) } } Why in this case when we tap the button and sheet comes in we go to the branch else even though we set title before isSheetPresented but it still somehow nil But what really drive me crazy is that if we change a little bit code to this: I just added another @State property 'number' and use it as the Button's title. In this scenario it works 😃 and Text in the sheet view appearing struct ContentView: View { @State private var title: String? @State private var number = 0 @State private var isSheetPresented = false var body: some View { Button((number)) { title = Sheet
Replies
2
Boosts
0
Views
156
Activity
Feb ’26
WebView on macOS
Hello everyone, I am currently working on integrating a WebView into my macOS application, intended to allow users to browse tutorial webpages directly within the app. Although I’ve followed an example that appears syntactically correct, the WebView does not render any webpage content. Below is a code snippet for reference: import SwiftUI import WebKit struct HelpWebView: View { @State private var toggle = false @State private var page = WebPage() private var url: URL { toggle ? URL(string: https://www.webkit.org)! : URL(string: https://www.swift.org)! } var body: some View { WebView(page) .onAppear { page.load(URLRequest(url: url)) } .onChange(of: toggle) { page.load(URLRequest(url: url)) } .toolbar { Button(Reload, systemImage: arrow.clockwise) { toggle.toggle() } } } } I would greatly appreciate any insights or suggestions on what might be causing this issue or how to resolve it. Thank you in advance for your help!
Topic: Safari & Web SubTopic: General Tags:
Replies
1
Boosts
0
Views
284
Activity
Feb ’26
Reply to Unexpected URLRepresentableIntent behaviour
Same, I tried using the onOpenURL method on my main SwiftUI view but I don't receive any url when launched from a URLRepresentableIntent
Topic: Machine Learning & AI SubTopic: General Tags:
Replies
Boosts
Views
Activity
Feb ’26
WebView on macOS
Hello everyone, I am currently working on integrating a WebView into my macOS application, intended to allow users to browse tutorial webpages directly within the app. Although I’ve followed an example that appears syntactically correct, the WebView does not render any webpage content. Below is a code snippet for reference: import SwiftUI import WebKit struct HelpWebView: View { @State private var toggle = false @State private var page = WebPage() private var url: URL { toggle ? URL(string: https://www.webkit.org)! : URL(string: https://www.swift.org)! } var body: some View { WebView(page) .onAppear { page.load(URLRequest(url: url)) } .onChange(of: toggle) { page.load(URLRequest(url: url)) } .toolbar { Button(Reload, systemImage: arrow.clockwise) { toggle.toggle() } } } } I would greatly appreciate any insights or suggestions on what might be causing this issue or how to resolve it. Thank you in advance for your help!
Topic: Safari & Web SubTopic: General Tags:
Replies
1
Boosts
0
Views
417
Activity
Feb ’26
Reply to Annoying popup window in Xcode Previews when the initial controller of the main storyboard is a macOS window
Thank you for replying, Albert. I'm focusing on developing a macOS app using non-SwiftUI app lifecycle. I would need some SwiftUI-AppKit bridging in this project, and I might want to use Xcode Previews also on AppKit view controllers. I'm encountering the problem described in the first post, meaning that I can't experience both Xcode Previews and Storyboard well as expected. That popup window can be moved away, but it reappears back at the initial position every time I write source code. I created the first post a bit prematurely. Sorry for that. I noticed that it's nothing about the entry point. Instead, it's about making any instance of window controller from storyboards — instantiateInitialController() I used before, and other instantiate… methods. Just make a window controller from a storyboard and show its window (e.g. in applicationDidFinishLaunching(_:)). Only NSStoryboard trigger the problem, while NSNib don't. I also noticed that the mechanism behind the problem also works when the
Replies
Boosts
Views
Activity
Feb ’26