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?
Search results for
swiftui
16,643 results found
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
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 !
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.
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?
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
Topic:
App & System Services
SubTopic:
Notifications
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
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:
Just tried the same experiment in a (newly created) AppKit app, exact same readability issue, so it's not SwiftUI-specific. Hmm, looks like I cannot edit the title of this post, or add an appkit tag.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
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  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.
Hello, I'm not aware of any replacement so ARCoachingOverlayView needs to be treated like a UIView in SwiftUI based apps as you've described. Please send us a feature request to provide a SwiftUI based coaching overlay. You can do this with the Feedback Assistant.
Topic:
Spatial Computing
SubTopic:
ARKit
Tags:
You're right, it is hardly readable on Mac in dark mode (OK on iOS). Could this provide a work around ? https://www.theswift.dev/posts/swiftui-alert-with-styled-buttons But may be worth a bug report.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
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
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
Thanks for the starting point, digged a bit deeper into what's the exact difference between the two: https://swiftui-garden.com/Shapes/ConcentricRectangle-and-ContainerRelativeShape
Topic:
UI Frameworks
SubTopic:
SwiftUI
(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: