Search results for

swiftui

16,643 results found

Post

Replies

Boosts

Views

Activity

Mounting FSKit with FSPathURLResource programatically in MacOS 26
Hi, I'm trying to mount my FSKit volume with a client app (SwiftUI). I already successfully did it with the mount command and I can instantiate my file-system with FSPathURLResource. Also, I managed to mount the file-system with DiskArbitration in a SwiftUI app, but I only managed to get it working with FSBlockDeviceResource. Is there a way to programmatically do it in a client app? Or is mount command currently the only option?
6
0
395
Sep ’25
ManipulationComponent + Warning messages in RealityView
Hi guys! I wanted to study this new ManipulationComponent(), but I keep getting a warning that I don’t understand, even in a very simple scenario. i don't have any collisions just binding the Manipulation the warning message is : ** Entity returned from EntityWrapper.makeEntity(context:) was already parented to another entity. This is not supported and may lead to unexpected behavior. SwiftUI adds entities to internally-managed entity hierarchies.** RealityView { content, attachments in if let loadedModel = try? await Entity(named: cloud_glb, in: realityKitContentBundle) { content.add(loadedModel) loadedModel.components.set(ManipulationComponent()) } Thanks !
3
0
204
Sep ’25
Rendering scene in RealityView to an Image
Is there any way to render a RealityView to an Image/UIImage like we used to be able to do using SCNView.snapshot() ? ImageRenderer doesn't work because it renders a SwiftUI view hierarchy, and I need the currently presented RealityView with camera background and 3D scene content the way the user sees it I tried UIHostingController and UIGraphicsImageRenderer like extension View { func snapshot() -> UIImage { let controller = UIHostingController(rootView: self) let view = controller.view let targetSize = controller.view.intrinsicContentSize view?.bounds = CGRect(origin: .zero, size: targetSize) view?.backgroundColor = .clear let renderer = UIGraphicsImageRenderer(size: targetSize) return renderer.image { _ in view?.drawHierarchy(in: view!.bounds, afterScreenUpdates: true) } } } but that leads to the app freezing and sending an infinite loop of [CAMetalLayer nextDrawable] returning nil because allocation failed. Same thing happens when I try return renderer.image { ctx in view.layer.render(in: ctx.
3
0
1.1k
Sep ’25
tvOS 18.5 SwiftUI Siri Remote click issue
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?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
1
0
145
Sep ’25
Reply to Alarmkit custom sound plays once
On the latest Xcode beta 7, and iOS Beta 9 I cannot get the custom alarm sound to work no matter what I try. I have tried in the simulator and on a physical device. The my-sound variable points to a local file in the project, and I’ve confirmed that Bundle.main can locate it. What am I doing wrong? import Foundation import AlarmKit import SwiftUI struct DefaultAlarmMetadata: AlarmMetadata { let label: String } struct DoesNotWork: View { public func buildAlarmConfiguration() async throws -> AlarmManager.AlarmConfiguration { let stopButton = AlarmButton(text: Stop, textColor: .red, systemImageName: stop.circle) let alertContent = AlarmPresentation.Alert( title: Mocked Alarm, stopButton: stopButton ) let presentation = AlarmPresentation(alert: alertContent) let metadata = DefaultAlarmMetadata( label: My Mocked Label ) if let soundPath = Bundle.main.path(forResource: my-sound, ofType: caf) { print(Sound file found at: (soundPath)) } else { print(Sound file not found in bundle) } return AlarmManager.Al
Sep ’25
Is it possible to read and write layout before render with SwiftUI?
I’m trying to keep a specific row visually stable while the data backing a ScrollView changes. Goal 1. Before updating model.items, capture the top row’s offset relative to the scroll view. 2. Mutate the observable state so SwiftUI recomputes layout — but don’t draw yet. 3. Read the new layout, compute the delta, and adjust the scroll position so the previously visible row stays put. 4. Only then draw the new frame. Reduced example @Observable final class SomeModel { var items: [SomeItem] = [/* ... */] } struct MyBox: View { @Environment(SomeModel.self) private var model var body: some View { ScrollView { VStack { ForEach(model.items, id: .id) { item in Color.red.frame(height: randomStableHeight(for: item.id)) } } } } } // Elsewhere: let oldRow = recordOldRow() // capture the row to stabilize model.items = generateNewItems() // mutate model (invalidates layout) let newPos = capturePreviousRowNewPosition(oldRow) // read new layout? restoreScrollPosition() // adjust so oldRow stays visually fixed // dr
1
0
73
Sep ’25
Reply to Is it possible to read and write layout before render with SwiftUI?
If you want to track the scroll position of an item within a scrollview and scroll back to that item at an given time you could use the scrollPosition API. The binding would automatticaly update the position of the prorpery as the user scrolls. You can then query the currently scrolled id by using the viewID(type:) When configuring a scroll position, SwiftUI will attempt to keep that position stable. For an edge, that means keeping a top aligned scroll view scrolled to the top if the content size changes. For a point, SwiftUI won’t attempt to keep that exact offset scrolled when the content size changes nor will it update to a new offset when that changes. For view identity positions, SwiftUI will attempt to keep the view with the identity specified in the provided binding visible when events occur that might cause it to be scrolled out of view by the system. For example: The data backing the content of a scroll view is re-ordered. The size of the scroll view changes, like when a wi
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’25
SwiftUI .destructive alert button in macOS dark mode — poor contrast
Here is a simple view to demonstrate the issue struct ContentView: View { @State private var isPresented = false var body: some View { VStack { Button(Test) { isPresented = true } } .alert(Test, isPresented: $isPresented, actions: { Button(Delete All, role: .destructive) {} }, message: { Text(Are You Sure?) }) .padding() } }``` Which results in ![example alert](https://developer.apple.com/forums/content/attachment/c6210120-d82e-4df5-a01a-fc5cb168e1bf title=Screenshot 2025-09-08 at 08.57.21.png;width=546;height=442) The destructive button is almost unreadable. WCAG score is 1.4, far below the minimum recommended 4.5. I found [this post](https://stackoverflow.com/q/66448869) on SO going back to Big Sur, but not on this forum. Any known workarounds (except for building my own dialogs, which I am trying to avoid)? Using confirmationDialog instead of alert does not make a difference.
6
0
137
Sep ’25
3rd-party closed-source XCFramework security
Hey! I am developing a macOS application with the help of an external vendor, who is supplying me with a closed-source XCFramework. In Xcode, when I import their XCFramework bundle, when running the app, or opening a SwiftUI preview, or interacting with the app in any form, I get the familiar dialog: [SDK name].framework Not Opened - Apple could not verify [SDK name].framework is free from malware that may harm your Mac or compromise privacy. (Regardless, the application can run on my machine.) But indeed, their cross-platform iOS/macOS XCFramework is not notarized at all (using spctl -a -t install), plus the macOS binary embedded is not code signed correctly (using codesign -d). The XCFramework itself is production code signed with a Developer ID certificate, however I believed the above issues to be valid. Now, I asked the vendor to provide a correctly distributed (so code signed and notarized) framework, however they pointed out that when I embed and sign the product in my app, it will be re-signe
3
0
167
Sep ’25
Adaptive automatic corner radius in containers with insets/paddings
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 t
Topic: UI Frameworks SubTopic: SwiftUI
3
0
650
Sep ’25
Reply to Drag-and-Drop from macOS Safari to NSItemProvider fails due to URL not being a file:// URL
(Re: previous answers - skip if you haven't followed the saga) Adding some context for the answer. I added AppKit specifically because it's not UIKit, as I didn't want an answer for iOS or ipadOS, but macOS. The only SwiftUI line is the onDrag, that I faithfully added to the line as the caller, but I didn't think I'd have a different DropHandler for macOS and ipadOS, the culprit seemingly being the onDrag SwiftUI part that tries to give me only the good thing on macOS, but somehow is unusable. As I repeated, I wanted to quickly iterate and used the hacks instead of trying to use the Async versions, where some versions aren't actually available. The final code will be in Async, thank you. My first SwiftUI app was with GCD because there wasn't an alternative back then. There's one now. But I'm also butting heads with SwiftData, where models cannot be Sendable, but Async are also required to be sendable, so I've had a lot of fun on this topic. With the nearly 200 trials I had to do in
Topic: UI Frameworks SubTopic: AppKit Tags:
Sep ’25