Summary
When a SwiftUI widget uses a Link containing an Image modified with .widgetAccentedRenderingMode (using any mode except .fullColor), tapping the image on the widget launches the app but does not pass the expected deep link URL to the SceneDelegate.
Steps to Reproduce
Create a SwiftUI Widget View with a Link:
struct ImageView: View {
var image: UIImage
var body: some View {
Link(URL(string: "myapp://image")!) {
Image(uiImage: image)
.resizable()
.widgetAccentedRenderingMode(.accentedDesaturated) // or any mode other than .fullColor
.scaledToFill()
.clipped()
}
}
}
Add Custom URL Scheme in Info.plist:
<dict>
<key>CFBundleURLName</key>
<string>com.company.myapp</string>
<key>CFBundleURLSchemes</key>
<array>
<string>myapp</string>
</array>
</dict>
Implement Deep Link Handling in SceneDelegate:
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
if let url = connectionOptions.urlContexts.first?.url {
handle(url)
}
}
func scene(_ scene: UIScene, openURLContexts urlContexts: Set<UIOpenURLContext>) {
if let url = urlContexts.first?.url {
handle(url)
}
}
private func handle(_ url: URL) {
// Process URL here
}
Run the application on a device or simulator.
Add the widget to the Home Screen.
Tap the image inside the widget.
Expected Result
The application launches and receives the URL in SceneDelegate, as expected.
Actual Result
The application launches, but the URL is not passed to SceneDelegate.
Both connectionOptions.urlContexts and openURLContexts are empty.
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
I'm trying to remove the extra top padding from the first section of a SwiftUI List using .plain style. I applied:
.contentMargins(.top, 0, for: .scrollContent)
But it seems to have no effect on iOS 17 and iOS 18.5 when section headers are present. However, it does work correctly on iOS 26 (tested with the latest Xcode beta).
Has anyone else run into this?
Is this a known issue or regression in iOS 17/18?
Is there any reliable workaround to remove or reduce the top padding in .plain list style when using section headers?
I have screenshots comparing iOS 18.5 and iOS 26 if needed.
Thanks in advance!
I'm currently developing a new app and uses Menu in it. The Menu cannot display text color normally and after if collapses my second text also disappears for a short time. FB19221675
Does anyone has this same issue in iOS 26?
Topic:
UI Frameworks
SubTopic:
SwiftUI
We've been trying to track down a non-reproducible issue for the past few months, and I'm wondering if anybody has encountered the same one.
Screenshots of the issue attached here. As you can see, the toolbar isn't respecting the safe area; there are many more issues that occur when this bug happens as well, such as the app being extremely laggy and sheets not opening.
Anecdotally, this seems to happen if the app is opened after not having been opened in a while (say, a day or so). It tends to happen first thing in the morning when I open the app, but as I mentioned, it's been very hard to reproduce.
I'm also wondering if it's a known SwiftUI navigation issue or if anyone has encountered this.
I'm building a visionOS app where users can place canvases into the 3D environment. These canvases are RealityKit entities that render web content using a WKWebView. The web view is regularly snapshotted, and its image is applied as a texture on the canvas surface.
When the user taps on a canvas, a WindowGroup is opened that displays the same shared WKWebView instance. This works great: both the canvas in 3D and the WindowGroup reflect the same live web content.
The canvas owns the WKWebView and keeps a strong reference to it.
Problem:
Once the user closes the WindowGroup, the 3D canvas stops receiving snapshot updates. The snapshot loop task is still running (verified via logs), but WKWebView.takeSnapshot(...) never returns — the continuation hangs forever. No error is thrown, no image is returned.
If the user taps the canvas again (reopening the window), snapshots resume and everything works again.
@MainActor
private func getSnapshot() async -> UIImage? {
guard !webView.isLoading else { return nil }
let config = WKSnapshotConfiguration()
config.rect = webView.bounds
config.afterScreenUpdates = true
return await withCheckedContinuation { continuation in
webView.takeSnapshot(with: config) { image, _ in
continuation.resume(returning: image)
}
}
}
What I’ve already verified:
The WKWebView is still in memory.
The snapshot loop (Task) is still running; it just gets stuck inside takeSnapshot(...).
I tried keeping the WKWebView inside a hidden UIWindow (with .alpha = 0.01, .windowLevel = .alert + 1, and isHidden = false).
Suspicion
It seems that once a WKWebView is passed into SwiftUI and rendered (e.g., via UIViewRepresentable), SwiftUI takes full control over its lifecycle. SwiftUI tells WebKit "This view got closed" and WebKit reacts by stopping the WKWebView. Even though it still exists in memory and is being hold by a strong reference to it in the Canvas-Entity.
Right now, this feels like a one-way path:
Starting from the canvas, tapping it to open the WindowGroup works fine.
But once the WindowGroup is closed, the WebView freezes, and snapshots stop until the view is reopened.
Questions
Is there any way under visionOS to:
Keep a WKWebView rendering after its SwiftUI view (WindowGroup) is dismissed?
Prevent WebKit from suspending or freezing the view?
Embed the view in a persistent system-rendered context to keep snapshotting functional?
For context, here's the relevant SwiftUI setup
struct MyWebView: View {
var body: some View {
if let webView = WebViewManager.shared.getWebView() {
WebViewContainer(webView: webView)
}
}
}
struct WebViewContainer: UIViewRepresentable {
let webView: WKWebView
func makeUIView(context: Context) -> UIView {
return webView
}
func updateUIView(_ uiView: UIView, context: Context) {}
}
SwiftUI.List allows for customization using .listItemTint, .tint, or .foregroundStyle. This can be used to color individual items in the list, other than the app's specified accent color.
Is there an equivalent feature to customize individual Tab's icon or label, when using TabView's SidebarAdaptableTabViewStyle, and its in the sidebar style.
From what I understand, there needs to be a modifier applied directly to Tab unlike List, and not just the label.
Since there isn't any color/tint modifiers, is it not possible?
When preparing SwiftUI code that uses List with .listStyle(.plain) for iOS 26, the by-default sticky section headers combined with the new translucent top-bars often causes unpleasantly overlapping text:
Two questions here:
Is there a modifier to make section headers non-sticky?
This would be helpful for cases where the translucent bar is a good fit and the section titles don't need to be sticky/pinned.
I found .listStyle(.grouped) can be an alternative in some cases, but this adds a gray background / additional padding to the section titles.
Is there a way to get a blurry material behind the section headers when they are sticking to the top bar?
This would be good for cases where the section header is important content-wise (like in the two-column example above or for a data list categorized using sections that should be always visible as a point of reference)
I found the scroll edge effects and .scrollEdgeEffectStyle(.hard, for: .top) does the trick for the top bar but doesn't affect attached sticky section headers (maybe it should?). Also I played around with .toolbarBackground(...) but this didn't do anything useful for a nav bar in my experiments.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Hi,
My app has an IAP and the view that let user to purchase is simply a ProductView. The purchase flow should be handled by the ProductView itself. I have tested the app with xcode storekit configuration, xcode run with sandbox account and also TestFlight environment as well. The purchase is triggered and the app feature is unlocked after purchase. However, I keep getting app review team feedback with the following problem:
Bug description: the purchase button is greyed out after we tapped on it, however, there's no purchase flow popped up
I have tried multiple things. Building with xcode cloud, removing the storekit configuration from the build scheme. But none can get the app review team to get through the problem.
The IAP is not available in certain region. In that case, the app will show a message. However, the app review attached an screenshot which shows the product view.
The view that allow users to purchase
if let product = store.products.first(where: { $0.id == "com.xxx.xxxxxxx" }) {
// If the product is available, show the ProductView
ProductView(id: product.id)
.productViewStyle(.compact)
} else {
// If the product is not available, show a message
Text("In-app purchase is not available in your region.")
}
The store class
@Published private(set) var products: [Product] = []
...
init() {
//To handle the parental approval flow
getUpdateTransaction()
}
func getUpdateTransaction() {
updates = Task {
for await update in StoreKit.Transaction.updates {
if let transaction = try? update.payloadValue {
await fetchActiveTransactions()
await transaction.finish()
}
}
}
}
Does anyone what can go wrong with ProductView? As this is part of the StoreKit API, I don't know what can go wrong. At least the purchase flow should be covered by it.
Also, is sandbox and TestFlight a good way to test IAP?
Thanks!
During the WWDC Session called "Design widgets for visionOS" the presenter says:
You can choose whether the background of your widget participates in tinting. If you opted out, for example to preserve a photo or illustration, make sure it still looks good alongside the selected color palette.
https://developer.apple.com/videos/play/wwdc2025/255
Unfortunately, this session has no example code. Can someone point me to the correct way to do this? Is there a modifier we can use on views?
When a user selects one the tint colors using the configuration screen, we would like to prevent some views from being tinted.
Greetings, Please type slowly, I'm new at this.
iOS 18.x.
Added search to a list, visibility toggled with a toolbar button, using this line of code:
.searchable(text: $searchText, isPresented: $isSearchPresented, placement:
.navigationBarDrawer(displayMode: .automatic), prompt: "Search...")
Realized I was re-stating defaults, changed it to this:
.searchable(text: $searchText, isPresented: $isSearchPresented, prompt: "Search...")
In both cases, it works great when in the middle of the list, just like I wanted. However, when I scroll to the top of the list, the serach field is displayed even when 'isPresented' is false. Is there any way to keep the search field hidden even at the top of the list?
..thanks!
In our app we have a view with a custom scroll implementation in a TabView. We would like to programmatically minimize (not hide) the TabView, like .tabBarMinimizeBehavior(...) does when a List is behind the tab bar and a user scrolls. I haven't found any view modifier that I can attach that allows me to do so, is this not possible? I would have expected something like
.tabBarMinimized($tabBarMinimized)
Topic:
UI Frameworks
SubTopic:
SwiftUI
I have several locations in my app where the user can search. He can search within the apps content or search for content from the web to add to the app.
i would like to use the tab view search box for both, but I don’t know how to do that. I currently have a tab with value search for the „web search“ and a list with .searchable for the in app content. The later one adds the search bar on top of the list.
W
hat’s the best way to modify this behavior?
Topic:
UI Frameworks
SubTopic:
SwiftUI
Hi everyone! I'm building a tvOS 18.5 app using SwiftUI in Xcode 16.4, and I'm having trouble reliably detecting button clicks from the 2nd generation Siri Remote.
.onMoveCommand(perform: handleMoveCommand)
func handleMoveCommand(_ direction: MoveCommandDirection) {
switch direction {
case .right: nextQuote()
case .left: previousQuote()
default: break
}
}
Swiping left or right on the remote's touch surface works as expected, the callback fires every time.
However, when I press the physical left/right buttons (outside the touch surface), the input is unreliable. Sometimes it registers, other times I need to press multiple times or nothing happens at all.
I’ve confirmed the view is .focusable(true) and bound with @FocusState.
Is this a known limitation or bug with .onMoveCommand on recent tvOS versions? Or is there a more robust way to handle physical Siri Remote button presses?
Hello Apple support,
I have this following code
Map(position: $mCam, selection: $lastSelection) {
// Display content conditionally based on camera scope.
// ^^^ works with user gesture, does not work with mapCameraKeyframeAnimator
}
.onMapCameraChange(frequency: .continuous , { context in
// save the camera scope
})
.mapCameraKeyframeAnimator(trigger: self.trigger, keyframes: { camera in
// frames
})
Context:
when logging, the .onMapCameraChange is updating. The content mapContentBuilder is running. But the content is NOT showing up on the map.
MapCircle, MapPolyline does not show! however, Marker works just fine
Question:
Anyone know How to indicate to MapKit Map view to draw the content?
Or how to have a slight "break" between animation keyframes, so map can catch up.
When using the fullScreenCover API in iOS 26, the content of the displayed view overlaps the content of the view that triggered the fullScreenCover. This issue is not present in iOS 18 and earlier versions.
Feedback ID: FB19165084
I have been trying to get the drag and drop to work on iOS 26 betas. Single drag is okay, but I thought this year we were getting multi-select drag added.
creating a simple object that can be dragged. Using the .draggable and added dropDestination which does trigger. The problem is the dragContainer does nothing. Not really clear what it is supposed to do.
How am I supposed to allow for multiple item drag and drop like the Photos app? In there you can start a drag and tap additional photos to add to the drag. I can do this with a UICollectionView, but not with SwiftUI.
struct DragObject: Codable, Identifiable, Transferable {
var index: Int
enum Keys: String, CodingKey {
case index
}
var id:Int {
index
}
public func encode(to encoder: any Encoder) throws {
var container = encoder.container(keyedBy: Keys.self)
try container.encode(self.index, forKey: .index)
}
static public var transferRepresentation: some TransferRepresentation {
CodableRepresentation(contentType: .json)
}
}
@available(iOS 26.0, *)
struct DragDropTestView: View {
@State var items : [DragObject] = (0..<100).map({ DragObject(index: $0) })
@State var selected : [DragObject.ID] = []
var body: some View {
let _ = Self._printChanges()
ScrollView {
Text("Selected \(selected)")
LazyVGrid(columns: [GridItem(.adaptive(minimum: 150, maximum: 180))],
alignment: .center,
spacing: 10)
{
ForEach(items, id: \.index) { item in
VStack {
Text("\(item.index)")
}
.frame(width: 100, height: 100)
.padding()
.background(Color.blue)
.cornerRadius(8)
.contentShape(.dragPreview, Circle())
.draggable(item)
.dropDestination(for: DragObject.self) { draggedItems, session in
print("Dragged Item Count: \(draggedItems.count)")
}
}
}
}
.dragContainer(for: DragObject.self, selection: selected){ ids in
dragItems(ids: ids)
}
}
func dragItems(ids: [Int]) -> [DragObject] {
return ids.map({ DragObject(index: $0)})
}
}
Hi,
I'm using one ttf font that simulate a bitmap look in my app. However, macOS renders all font with anti-aliasing. On those kind of font, that introduce some artefacts.
Is there a way to disable anti-aliasing or some tricks that would make like there were no anti-aliasing?
Thanks.
With the correct corner radius changing in iOS 26, I wondered if there is a way to get properly rounded corners inside containers like sheets without hard-coding a constant value.
Here's the results of some experiments I did, example code below.
The new in Beta 4 ConcentricRectangle seems nice. Notable here is that it doesn't pick up the larger corner radii from the device corners:
If you want all the corners rounded, the isUniform parameter of ConcentricRectangle seems helpful. It doesn't apply the corners in a View in the middle though, not sure if this is an oversight or if this has some purpose:
ContainerRelativeShape looks ... interesting ... as of Beta 4, with the larger bottom corners rounded according to the device corners, but the actual bottom corners not fitting the device corners.
With ContainerRelativeShape one can also get the middle part to have proper rounded corners in this example ... if you set the outer .containerShape(RoundedRectangle(cornerRadius: 36)) yourself. Notable here is that it then actually adapts all corners of the last card to the larger device corner radius - why it does that even with the smaller radius being explicitly set as containerShape is beyond my imagination.
ContainerRelativeShape and ConcentricRectangle both feel quite similar to me, but different in ways that are not clear to me after reading the documentation. I wouldn't know when to pick which / I am not sure if these two should really be two separate things... Any insights here?
I was also hoping to find a way to read the cornerRadius (both device corner radius and sheet container radius) for more complex custom-shaped views, but currently there seems no way to do that. The new in iOS 26 Beta 4 GeometryReader containerCornerInsets sounded a bit like it, but it seems of no use here, it's always zero. docs talk about windowing controls and values can be seen on iPad when the red/yellow/green window buttons become visible, so it seems unrelated here.
Example code AdaptiveCorners.swift
import SwiftUI
enum Experiment: String, CaseIterable, Identifiable {
case form
case concentricRect
case uniformConcentricRect
case containerRelative
case containerRelativeWithContainerShape
case containerCornerInsets
var title: String {
self.rawValue
}
var id: String {
self.rawValue
}
}
struct ContentView: View {
@State var experiment : Experiment? = .concentricRect
var body: some View {
NavigationStack {
Form {
Picker("Experiment", selection: $experiment) {
ForEach(Experiment.allCases, id: \.self) { experiment in
Text(experiment.title).tag(experiment)
}
}
.pickerStyle(.inline)
}
}
.sheet(item: $experiment) { experiment in
Group {
switch(experiment) {
case .form:
Form {
Section {
Text("Form + Section")
Text("Form + Section")
}
}
case .concentricRect:
ShapeView {
ConcentricRectangle()
}
case .uniformConcentricRect:
ShapeView {
ConcentricRectangle(corners: .concentric, isUniform: true)
}
case .containerRelative:
ShapeView {
ContainerRelativeShape()
}
case .containerRelativeWithContainerShape:
ShapeView {
ContainerRelativeShape()
}
.containerShape(RoundedRectangle(cornerRadius: 36))
case .containerCornerInsets:
GeometryReader { geometry in
Form {
Text(String(describing: geometry.containerCornerInsets))
}
}
}
}
.presentationDetents([.medium, .large])
}
}
}
struct ShapeView<S : Shape> : View {
@ViewBuilder let content: () -> S
var body: some View {
ScrollView([.vertical]) {
VStack {
HStack {
content()
.fill(Color.yellow)
.frame(height: 80)
.frame(maxWidth: .infinity)
content()
.fill(Color.orange)
.frame(height: 80)
.frame(maxWidth: .infinity)
}
content()
.fill(Color.green)
.frame(height: 80)
.frame(maxWidth: .infinity)
}
.padding()
}
}
}
#Preview {
ContentView()
}
Topic:
UI Frameworks
SubTopic:
SwiftUI
Hello everyone, I am having an issue where the attributed text that I have in my UITextView is not scaling dynamically with phone text size, whenever I remove the attributed text logic, it scales fine, however, with it, it stays at a set font size.
struct AutoDetectedClickableDataView: UIViewRepresentable {
let text: String
@Binding var height: CGFloat
func makeUIView(context: Context) -> UITextView {
let textView = UITextView()
textView.dataDetectorTypes = [.phoneNumber, .address, .link]
textView.isEditable = false
textView.isScrollEnabled = false
textView.backgroundColor = .clear
textView.font = UIFont.preferredFont(forTextStyle: .body) /*UIFontMetrics(forTextStyle: .body).scaledFont(for: UIFont.systemFont(ofSize: 16.0)) */
textView.adjustsFontForContentSizeCategory = true
textView.textContainer.lineBreakMode = .byWordWrapping
textView.textContainerInset = .zero
textView.textContainer.lineFragmentPadding = 0
textView.translatesAutoresizingMaskIntoConstraints = false
textView.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
textView.setContentHuggingPriority(.defaultHigh, for: .horizontal)
return textView
}
func updateUIView(_ uiView: UITextView, context: Context) {
let attributed = NSMutableAttributedString(string: text, attributes: [
.font: UIFont.preferredFont(forTextStyle: .body)
])
let detector = try? NSDataDetector(types: NSTextCheckingResult.CheckingType.address.rawValue |
NSTextCheckingResult.CheckingType.link.rawValue |
NSTextCheckingResult.CheckingType.phoneNumber.rawValue)
detector?.enumerateMatches(in: text, options: [], range: NSRange(location: 0, length: text.utf16.count)) { match, _, _ in
guard let match = match else { return }
attributed.addAttributes([
.foregroundColor: UIColor.systemBlue,
.underlineStyle: NSUnderlineStyle.single.rawValue,
], range: match.range)
}
uiView.attributedText = attributed
// uiView.text = text
DispatchQueue.main.async {
uiView.layoutIfNeeded()
let fittingSize = CGSize(width: uiView.bounds.width, height: .greatestFiniteMagnitude)
let size = uiView.sizeThatFits(fittingSize)
height = size.height
}
}
}
Can anyone help me why i cannot move on?
I thought I had finished the instrcutions. However, it seems that i missed something that I didnt find out.