I'm very happy with the new badge property of UIBarButtonItem, but unfortunately it doesn't work yet on a UIToolbar object.
The following code does change the tint color of the button to pink, which proves the button object exists, but there is no visible badge after running the code:
if let button = toolbarItems?.first {
button.badge = .count(123) // Does nothing
button.tintColor = .systemPink // Works
}
Do I overlook something, or is this just not implemented yet? Or is this limitation 'by design'? (That would be a MAJOR disappointment)
Explore the various UI frameworks available for building app interfaces. Discuss the use cases for different frameworks, share best practices, and get help with specific framework-related questions.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Someone smarter than me please tell me if this will work... I want to have an edit screen for a SwiftData class. Auto Save is on, but I want to be able to revert changes. I have read all about sending a copy in, sending an ID and creating a new context without autosave, etc.
What about simply creating a second set of ephemeral values in the actual original model. initialize them with the actual fields. Edit them and if you save changes, migrate that back to the permanent fields before returning.
Don't have to manage a list of @State variables corresponding to every model field, and don't have to worry about a second model context.
Anyone have any idea of the memory / performance implications of doing it this way, and if it is even possible? Does this just make a not quite simple situation even more complicated? Haven't tried yet, just got inspiration from reading some medium content on attributes on my lunch break, and wondering if I am just silly for considering it.
I added a canvas view using PDFPageOverlayViewProvider. When I zoom the PDFView, the drawing is scaled, but its quality becomes blurry. How can I fix this?
import SwiftUI
import PDFKit
import PencilKit
import CoreGraphics
struct ContentView: View {
var body: some View {
if
let url = Bundle.main.url(forResource: "sample", withExtension: "pdf"),
let data = try? Data(contentsOf: url),
let document = PDFDocument(data: data)
{
PDFRepresentableView(document: document)
} else {
Text("fail")
}
}
}
#Preview {
ContentView()
}
struct PDFRepresentableView: UIViewRepresentable {
let document: PDFDocument
let pdfView = PDFView()
func makeUIView(context: Context) -> PDFView {
pdfView.displayMode = .singlePageContinuous
pdfView.usePageViewController(false)
pdfView.displayDirection = .vertical
pdfView.pageOverlayViewProvider = context.coordinator
pdfView.document = document
pdfView.autoScales = false
pdfView.minScaleFactor = 0.7
pdfView.maxScaleFactor = 4
return pdfView
}
func updateUIView(_ uiView: PDFView, context: Context) {
// Optional: update logic if needed
}
func makeCoordinator() -> CustomCoordinator {
return CustomCoordinator(parent: self)
}
}
class CustomCoordinator: NSObject, PDFPageOverlayViewProvider, PKCanvasViewDelegate {
let parent: PDFRepresentableView
init(parent: PDFRepresentableView) {
self.parent = parent
}
func pdfView(_ view: PDFView, overlayViewFor page: PDFPage) -> UIView? {
let result = UIView()
let canvasView = PKCanvasView()
canvasView.drawingPolicy = .anyInput
canvasView.tool = PKInkingTool(.pen, color: .blue, width: 20)
canvasView.translatesAutoresizingMaskIntoConstraints = false
result.addSubview(canvasView)
NSLayoutConstraint.activate([
canvasView.leadingAnchor.constraint(equalTo: result.leadingAnchor),
canvasView.trailingAnchor.constraint(equalTo: result.trailingAnchor),
canvasView.topAnchor.constraint(equalTo: result.topAnchor),
canvasView.bottomAnchor.constraint(equalTo: result.bottomAnchor)
])
for subView in view.documentView?.subviews ?? [] {
subView.isUserInteractionEnabled = true
}
result.layoutIfNeeded()
return result
}
}
I found this api may fail after iOS18.0
open func request(_ transaction: CXTransaction, completion: @escaping ((any Error)?) -> Void)
But I can not reproduce it and it will recover after relaunch the app.
Is there any issue for this or guide line after iOS18?
Is there a way to get a sheet on the side over an interactive view with a proper glass background on iPad? Ideally, including being able to drag the sheet between medium/large-height sizes (like a sheet with presentationDetents on iPhone), similar to the Maps app:
I tried the NavigationSplitView like in the NavigationCookbook example. This is somewhat like it, but it's too narrow (sidebar-like) and doesn't get the full navigation bar:
I also played around with .sheet and .presentationDetents and the related modifiers, thinking I could make the sheet appear to the side; but no luck here. It seems to have all the correct behaviors, but it's always presented form-like in the center:
Example code for the sheet:
import SwiftUI
import MapKit
struct ContentView: View {
var body: some View {
Map()
.sheet(isPresented: .constant(true)) {
NavigationStack {
VStack {
Text("Hello")
NavigationLink("Show Foo") {
Text("Foo")
.navigationTitle("Foo")
.containerBackground(Color.clear, for: .navigation)
}
}
}
.presentationDetents([.medium, .large])
.presentationBackgroundInteraction(.enabled)
}
}
}
I also tried placing the NavigationStack as an overlay and putting a .glassEffect behind it. From the first sight, this looks okay-ish on beta 3, but seems prone to tricky gotchas and edge cases around the glass effects and related transitions. Seems like not a good approach to me, building such navigational containers myself has been a way too big time-sink for me in the past...
Anyway, example code for the overlay approach:
import SwiftUI
import MapKit
struct ContentView: View {
var body: some View {
Map()
.overlay(alignment: .topLeading) {
NavigationStack {
VStack {
Text("Hello")
NavigationLink("Show Foo") {
ScrollView {
VStack {
ForEach(1...30, id: \.self) { no in
Button("Hello world") {}
.buttonStyle(.bordered)
}
}
.frame(maxWidth: .infinity)
}
.navigationTitle("Foo")
.containerBackground(Color.clear, for: .navigation)
}
}
.containerBackground(Color.clear, for: .navigation)
}
.frame(width: 400)
.frame(height: 600)
.glassEffect(.regular, in: .rect(cornerRadius: 22))
.padding()
}
}
}
Do I miss something here or is this not possible currently with built-in means of the SwiftUI API?
Topic:
UI Frameworks
SubTopic:
SwiftUI
I'm developing software that implements functionality for third party touch screens. It provides features such as having touch gestures trigger mouse clicks and drags, among other possible actions.
One of its features allows keyboard focus to return to whichever app originally had it prior to performing a touch gesture. Previously it worked by recording the current frontmost app when a touch action starts, and then when all touch actions have concluded, calling NSRunningApplication.activateWithOptions and passing NSApplicationActivateIgnoringOtherApps.
However, in macOS 14 and later, this no longer works, as NSRunningApplication.activateWithOptions is deprecated. The new API provides a way for the current frontmost app to yield frontmost to whichever app is being activated with the new functions NSRunningApplication.yieldActivationToApplication and NSRunningApplication.activate, but in my case it just silently fails, presumably because my app in that moment is not frontmost. (However there is no error code provided for me to be able to find out what exactly the issue is.)
Is there a supported way I can fix this feature in macOS 14 and later?
Subject: Need Assistance with App Clip Invocation via URL
Hello Developers,
I’m currently facing an issue with invoking my App Clip through a URL, specifically when the link is shared via iMessage or Email. Instead of launching the App Clip, the URL redirects to the website.
Here’s my current configuration:
Approved App with an App Clip
Universal Links functioning correctly within the App (verified through AASA file hosted on the website)
Associated Domain Entitlements included for both the App and the App Clip
Universal Link is expected to invoke the App Clip if the App isn’t installed
Advanced Experience configured in App Store Connect
The default experience URL from App Store Connect successfully triggers the App Clip, but my custom URL does not.
I suspect I might be missing a crucial configuration step. Has anyone encountered a similar issue or have suggestions on what else I should verify?
Thank you in advance for your help!
This is obviously a user error, but I've been working on different possibilities for a couple of days and nothing works. The problem is my Section in the following code doesn't expand or collapse when I click on the chevron:
`class AstroCat {
var title: String
var contents: [ String ]
var isExpanded: Bool
init(title: String, contents: [String], isExpanded: Bool) {
self.title = title
self.contents = contents
self.isExpanded = isExpanded
}
}
struct TestView: View {
@Binding var isShowingTargetSelection: Bool
@State var catalog: AstroCat
@State private var expanded = false
var body: some View {
NavigationStack {
List {
Section(catalog.title, isExpanded: $catalog.isExpanded) {
ForEach(catalog.contents, id: \.self) { object in
Text(object)
}
}
}
.navigationTitle("Target")
.listStyle(.sidebar)
}
}
}
#Preview {
struct TestPreviewContainer : View {
@State private var value = false
@State var catalog = AstroCat(title: "Solar System", contents: ["Sun", "Mercury", "Venus", "Earth"], isExpanded: true)
var body: some View {
TestView(isShowingTargetSelection: $value, catalog: catalog)
}
}
return TestPreviewContainer()
}`
If I change the "isExpanded: $catalog.isExpanded" to just use the local variable "expanded", then it works, so I think I have the basic SwiftUI pieces correct. But using a boolean inside of the class doesn't seem to work (the section just remains expanded or collapsed based on the initial value of the class variable).
Any hints? Am I not specifying the binding correctly? (I've tried a bunch of alternatives)
Thanks for the help,
Robert
Hello,
We have a Xamarin app in the stores (I know, Xamarin is EOL). We are working on a new version, but do to planning issues, it's not yet ready to be published.
We now have a customer who complains that our app is crashing on iOS 26 beta.
Our biggest question now is: will it be fixed in the stable release of iOS 26 or will we get a lot of complains around mid September?
We currently don't have a device running iOS 26.
The crash logs show multiple devices: iPhone 15, iPhone 15 Pro Max and iPhone 16 Pro
This is the crash log:
Runtime.ThrowNSException (System.IntPtr ns_exception)
SIGABRT: Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: Modifications to the layout engine must not be performed from a background thread after it has been accessed from the main thread. Native stack trace: 0 CoreFoundation 0x00000001a2e438dc 44CF748C-19F2-31C4-A0F1-143E32768AF1 + 825564 1 libobjc.A.dylib 0x000000019ffa17a4 objc_exception_throw + 88 2 CoreAutoLayout 0x00000001c9afb3a4 84BC5753-1758-31EE-9293-D54061CA6C7A + 5028 3 CoreAutoLayout 0x00000001c9afb734 84BC5753-1758-31EE-9293-D54061CA6C7A + 5940 4 CoreAutoLayout 0x00000001c9afb404 84BC5753-1758-31EE-9293-D54061CA6C7A + 5124 5 CoreAutoLayout 0x00000001c9afaee8 84BC5753-1758-31EE-9293-D54061CA6C7A + 3816 6 UIKitCore 0x00000001a5a8bac8 ABE178BE-C241-3474-A192-70F042F71BF4 + 162504 7 UIKitCore 0x00000001a5b62760 ABE178BE-C241-3474-A192-70F042F71BF4 + 1042272 8 UIKitCore 0x00000001a5c98228 ABE178BE-C241-3474-A192-70F042F71BF4 + 2310696 9 UIKitCore 0x00000001a5a8b674 ABE178BE-C241-3474-A192-70F042F71BF4 + 161396 10 UIKitCore 0x00000001a5a8c134 ABE178BE-C241-3474-A192-70F042F71BF4 + 164148 11 UIKitCore 0x00000001a7326898 ABE178BE-C241-3474-A192-70F042F71BF4 + 25962648 12 QuartzCore 0x00000001a4db7d98 56B9FC0F-1E8F-3B5F-BE34-7DDB9A5D7375 + 703896 13 QuartzCore 0x00000001a4d9a810 56B9FC0F-1E8F-3B5F-BE34-7DDB9A5D7375 + 583696 14 QuartzCore 0x00000001a4db945c 56B9FC0F-1E8F-3B5F-BE34-7DDB9A5D7375 + 709724 15 QuartzCore 0x00000001a4d7a30c 56B9FC0F-1E8F-3B5F-BE34-7DDB9A5D7375 + 451340 16 QuartzCore 0x00000001a4da6fc4 56B9FC0F-1E8F-3B5F-BE34-7DDB9A5D7375 + 634820 17 Time.iOS 0x0000000105ebb6b0 sqlite3_sourceid + 19991196 18 Time.iOS 0x0000000105dfe4f8 sqlite3_sourceid + 19216612 19 Time.iOS 0x0000000106094154 sqlite3_sourceid + 21927232 20 Time.iOS 0x0000000104efe21c sqlite3_sourceid + 3487240 21 Time.iOS 0x0000000104efb90c sqlite3_sourceid + 3476728 22 Time.iOS 0x0000000104efb70c sqlite3_sourceid + 3476216 23 Time.iOS 0x0000000104efb690 sqlite3_sourceid + 3476092 24 Time.iOS 0x0000000104efe384 sqlite3_sourceid + 3487600 25 Time.iOS 0x00000001051dea20 sqlite3_sourceid + 6503948 26 Time.iOS 0x0000000107a17744 sqlite3_sourceid + 48679728 27 Time.iOS 0x0000000107ad1390 sqlite3_sourceid + 49440636 28 Time.iOS 0x0000000107ad6d2c sqlite3_sourceid + 49463576 29 Time.iOS 0x0000000107b1efe0 sqlite3_sourceid + 49759180 30 Time.iOS 0x0000000107b1ed6c sqlite3_sourceid + 49758552 31 libsystem_pthread.dylib 0x00000002329c9424 _pthread_start + 136 32 libsystem_pthread.dylib 0x00000002329c58cc thread_start + 8
Runtime.ThrowNSException (System.IntPtr ns_exception)
Runtime.throw_ns_exception (System.IntPtr exc)
(wrapper native-to-managed) ObjCRuntime.Runtime.throw_ns_exception(intptr)
(wrapper managed-to-native) ObjCRuntime.Messaging.objc_msgSend(intptr,intptr)
CATransaction.Commit ()
CADisplayLinkTicker.StartThread ()
ThreadHelper.ThreadStart_Context (System.Object state)
ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx)
ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx)
ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state)
ThreadHelper.ThreadStart ()
(wrapper managed-to-native) ObjCRuntime.Messaging.objc_msgSend(intptr,intptr)
CATransaction.Commit ()
CADisplayLinkTicker.StartThread ()
ThreadHelper.ThreadStart_Context (System.Object state)
ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx)
ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx)
ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state)
ThreadHelper.ThreadStart ()
kind regards
Topic:
UI Frameworks
SubTopic:
General
I have a uisegmentedcontrol used as a customview on a right uibarbuttonitem. It has two segments. With iOS26, no matter where I tap it, it always triggers the first segment.
This worked fine in ios18.
Topic:
UI Frameworks
SubTopic:
UIKit
Before I file a bug report I wanted to verify that I'm not missing something.
If I setup a view controller in a navigation controller and I add a view with a constraint that lines it up with the view controller's view's layoutMarginsGuide (leadingAnchor or trailingAnchor), in several cases the view will not line up with buttons added in the navigation bar. Under iOS 18 everything lines up as expected.
To demonstrate, create a new iOS project based on Swift/Storyboard. Setup the storyboard to show a UINavigationController with one UIViewController. Then in ViewController.swift (the one embedded in the navigation controller), use the following code:
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .yellow
title = "Layout Margins"
let leftCancel = UIBarButtonItem(systemItem: .cancel)
navigationItem.leftBarButtonItem = leftCancel
let rightCancel = UIBarButtonItem(systemItem: .cancel)
navigationItem.rightBarButtonItem = rightCancel
let leftView = UIView()
leftView.backgroundColor = .blue
leftView.translatesAutoresizingMaskIntoConstraints = false
self.view.addSubview(leftView)
let rightView = UIView()
rightView.backgroundColor = .red
rightView.translatesAutoresizingMaskIntoConstraints = false
self.view.addSubview(rightView)
NSLayoutConstraint.activate([
leftView.widthAnchor.constraint(equalToConstant: 80),
leftView.heightAnchor.constraint(equalToConstant: 80),
leftView.leadingAnchor.constraint(equalTo: self.view.layoutMarginsGuide.leadingAnchor),
leftView.topAnchor.constraint(equalTo: self.view.layoutMarginsGuide.topAnchor),
rightView.widthAnchor.constraint(equalToConstant: 80),
rightView.heightAnchor.constraint(equalToConstant: 80),
rightView.trailingAnchor.constraint(equalTo: self.view.layoutMarginsGuide.trailingAnchor),
rightView.topAnchor.constraint(equalTo: self.view.layoutMarginsGuide.topAnchor),
])
}
}
This adds a "Cancel" button to both ends of the navigation bar and it adds two little square views lined up with the leading and trailing layout margins.
Here's the results:
iPad running iPadOS 26 beta 3 (note the misalignment). This is really jarring when trying to align another glass button below the cancel button:
iPad running iPadOS 18.5 (aligned just fine):
iPhone in portrait running iOS 26 beta (aligned just fine):
iPhone in landscape running iOS 26 beta (no alignment at all):
iPhone in portrait running iOS 18.5 (aligned just fine):
iPhone in landscape running iOS 18.5 (aligned just fine):
Under iOS 26 on an iPhone (simulator at least) in portrait, the cancel buttons line up with the colored squares. That's good. In landscape, the colored squares have much larger margins as expected (due to the larger safe areas caused by the notch), but the cancel buttons in the navigation bar are not using the same margins. This one is debatable. Under iOS 18 the cancel buttons use larger margins to match the larger safe area. But I can see why under iOS 26 they changed this since the navigation bar doesn't interfere with the notch. But it's inconsistent.
Under iOS 26 on an iPad (simulator at least), it's wrong in any orientation. Despite the lack of any notch or need for a larger safe area, the colored squares are indented just a bit more than the buttons in the navigation bar. I see no reason for this. Under iOS 18 everything lines up as expected.
My real question at this point: Is the mismatched margins on an iPad under iOS 26 between the buttons in the navigation bar and other views added to the view controller a likely bug or am I missing something?
I work on a universal app that targets both iPhone and iPad. Our iPad app currently requires full screen. When testing on the latest iPadOS 26 beta, we see the following warning printed to the console:
Update the Info.plist: 1) `UIRequiresFullScreen` will soon be ignored. 2) Support for all orientations will soon be required.
It will take a fair amount of effort to update our app to properly support presentation in a resizable window. We wanted to gauge how urgent this change is. Our testing has shown that iPadOS 26 supports our app in a non-resizable window.
Can someone from Apple provide any guidance as to how soon “soon” is? Will UIRequiresFullScreen be ignored in iPadOS 26? Will support for all orientations be required in iPadOS 26?
In TabView, when I open a view in a Tab, and I switch to another Tab, but the View lifecycle of the view in the old Tab is still not over, and the threads of some functions are still in the background. I want to completely end the View lifecycle of the View in the previously opened tab when switching Tab. How can I do it? Thank you!
Project minimum iOS deployment is set to 16.4. When running this simple code in console we receive "Observation tracking feedback loop detected!" and map is unusable.
Run code:
Map(coordinateRegion: .constant(.init()))
Console report:
...
Observable object key path '\_UICornerProvider.<computed 0x00000001a2768bc0 (Optional<UICoordinateSpace>)>' changed; performing invalidation for [layout] of: <_TtGC7SwiftUI21UIKitPlatformViewHostGVS_P10$1a57c8f9c32PlatformViewRepresentableAdaptorGV15_MapKit_SwiftUI8_MapViewGSaVS2_P10$24ce3fc8014AnnotationData____: 0x10acc2d00; baseClass = _TtGC5UIKit22UICorePlatformViewHostGV7SwiftUIP10$1a57c8f9c32PlatformViewRepresentableAdaptorGV15_MapKit_SwiftUI8_MapViewGSaVS3_P10$24ce3fc8014AnnotationData____; frame = (0 0; 353 595); anchorPoint = (0, 0); tintColor = UIExtendedSRGBColorSpace 0.333333 0.333333 0.333333 1; layer = <CALayer: 0x12443a430>>
Observable object key path '\_UICornerProvider.<computed 0x00000001a2768bc0 (Optional<UICoordinateSpace>)>' changed; performing invalidation for [layout] of: <_MapKit_SwiftUI._SwiftUIMKMapView: 0x10ae8ce00; frame = (0 0; 353 595); clipsToBounds = YES; autoresize = W+H; layer = <CALayer: 0x113beb7e0>>
Observable object key path '\_UICornerProvider.<computed 0x00000001a2768bc0 (Optional<UICoordinateSpace>)>' changed; performing invalidation for [layout] of: <_MapKit_SwiftUI._SwiftUIMKMapView: 0x10ae8ce00; frame = (0 0; 353 595); clipsToBounds = YES; autoresize = W+H; layer = <CALayer: 0x113beb7e0>>
Observable object key path '\_UICornerProvider.<computed 0x00000001a2768bc0 (Optional<UICoordinateSpace>)>' changed; performing invalidation for [layout] of: <_MapKit_SwiftUI._SwiftUIMKMapView: 0x10ae8ce00; frame = (0 0; 353 595); clipsToBounds = YES; autoresize = W+H; layer = <CALayer: 0x113beb7e0>>
Observation tracking feedback loop detected! Make a symbolic breakpoint at UIObservationTrackingFeedbackLoopDetected to catch this in the debugger. Refer to the console logs for details about recent invalidations; you can also make a symbolic breakpoint at UIObservationTrackingInvalidated to catch invalidations in the debugger. Object receiving repeated [layout] invalidations: <_TtGC7SwiftUI21UIKitPlatformViewHostGVS_P10$1a57c8f9c32PlatformViewRepresentableAdaptorGV15_MapKit_SwiftUI8_MapViewGSaVS2_P10$24ce3fc8014AnnotationData____: 0x10acc2d00; baseClass = _TtGC5UIKit22UICorePlatformViewHostGV7SwiftUIP10$1a57c8f9c32PlatformViewRepresentableAdaptorGV15_MapKit_SwiftUI8_MapViewGSaVS3_P10$24ce3fc8014AnnotationData____; frame = (0 0; 353 595); anchorPoint = (0, 0); tintColor = UIExtendedSRGBColorSpace 0.333333 0.333333 0.333333 1; layer = <CALayer: 0x12443a430>>
Observation tracking feedback loop detected! Make a symbolic breakpoint at UIObservationTrackingFeedbackLoopDetected to catch this in the debugger. Refer to the console logs for details about recent invalidations; you can also make a symbolic breakpoint at UIObservationTrackingInvalidated to catch invalidations in the debugger. Object receiving repeated [layout] invalidations: <_MapKit_SwiftUI._SwiftUIMKMapView: 0x10ae8ce00; frame = (0 0; 353 595); clipsToBounds = YES; autoresize = W+H; layer = <CALayer: 0x113beb7e0>>
IDE: Xcode 26 Beta 3
Testing device: iPhone 15 Pro iOS 26 Beta 3
MacOS: Tahoe 26 Beta 3
When integrating the Automatic Sign-In API on physical devices (iPhone SE with iOS 26.0 and Apple TV with tvOS 26.0), the call to requestAutoSignInAuthorization() results in an immediate error stating "Service temporarily unavailable." This prevents the app from obtaining the necessary authorization context to proceed with token updates and the Automatic Sign-In flow.
The issue occurs specifically at the authorization request stage and does not progress to calling updateAutoSignInToken(), since it does not acquire conditions for it. All entitlement and sandbox setup have been verified and are correctly configured.
Error:
Error Domain=VSErrorDomain Code=3 "The service is temporarily unavailable." UserInfo={NSLocalizedDescription=The service is temporarily unavailable., NSLocalizedRecoverySuggestion=Please try again later.}
Topic:
UI Frameworks
SubTopic:
General
My view structure in UIKit is like this: UITabBarController (with UITabBar) -> UINavigationController -> UIToolbar (by setting self.navigationController.toolbarHidden = NO). The toolbar is shown in red in the picture. I'm using it like so:
self.navigationController.toolbarHidden = NO;
self.toolbarItems = @[element1, element2];
This toolbar does work fine up to iOS 18.5 but it does not show up when compiling using iOS 26 Beta 3. Is this a bug?
I don't see any deprecation in the documentation about it. Am I doing something wrong?
Although it doesn't seem to be a forbidden practice, placing toolbar items in the bottom bar of a modal Sheet (which has its own NavigationStack) triggers massive layout warnings.
The same thing occurs when using the .searchable(...) view modifier inside a Sheet (which affects the bottom bar too).
LayoutWarning.txt
Hi everyone,
I’m experimenting with the new ScreenTime DeviceActivityReport view in SwiftUI (iOS 17 / Xcode 15).
My goal is to show the report inside a Button (or, more generally, capture any tap on it) so that I can push a detail screen when the user selects it.
Here’s the minimal code that reproduces the issue:
import FamilyControls
import DeviceActivity
import SwiftUI
struct ScreenTimeView: View {
let center = AuthorizationCenter.shared
@State private var context: DeviceActivityReport.Context =
.init(rawValue: "Total Activity")
@State private var filter = DeviceActivityFilter(
segment: .hourly(
during: Calendar.current.dateInterval(of: .day, for: .now)!
),
users: .all,
devices: .init([.iPhone, .iPad])
)
var body: some View {
ZStack {
DeviceActivityReport(context, filter: filter)
}
.onAppear {
Task {
do {
try await center.requestAuthorization(for: .individual)
} catch {
print("Authorization failed:", error)
}
}
}
}
}
struct ContentView: View {
var body: some View {
ScrollViewReader { _ in
ScrollView(showsIndicators: false) {
VStack {
Button {
print("BUTTON TAPPED") // ← never fires
} label: {
ScreenTimeView()
.frame(height: UIScreen.main.bounds.height * 1.4)
}
}
}
}
}
}
**
What happens**
DeviceActivityReport renders correctly with hourly bars.
Tapping anywhere inside the Button does not trigger print("BUTTON TAPPED").
I’ve tried replacing Button with .onTapGesture, adding .contentShape(Rectangle()), and .allowsHitTesting(true), but nothing registers.
What I’ve checked
Authorisation succeeds—calling code in .onAppear prints no errors.
Removing DeviceActivityReport and replacing it with a plain Rectangle() lets the tap gesture fire, so the issue seems specific to DeviceActivityReport.
I'm running into a persistent problem with the iOS 18.5 simulator in Xcode 26 beta 2. I have built a very simple test app with a storyboard that includes only a toolbar added to the ViewController scene in the storyboard. The test app runs fine in iOS 26 simulators.When I try to run it in the iOS 18.5 simulator for iPhone Pro or iPad (16), it fails while unarchiving the storyboard (as far as I can tell) with this error message in the Xcode console:
*** Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named TtGC5UIKit17UICoreHostingViewVCS_21ToolbarVisualProvider8RootView because no class named TtGC5UIKit17UICoreHostingViewVCS_21ToolbarVisualProvider8RootView was found; the class needs to be defined in source code or linked in from a library (ensure the class is part of the correct target)'
terminating due to uncaught exception of type NSException
CoreSimulator 1043 - Device: iPad (A16) (3E70E25F-8434-4541-960D-1B58EB4037F3) - Runtime: iOS 18.5 (22F77) - DeviceType: iPad (A16)
I'd love a simple workaround for this.
I want to make an agent application in SwiftUI.
It would be setup as a login item and have no dock icon and display no windows on start.
I used AlertScene at first, but it is unavailable on macOS 14 which is my deployment target.
Is there a way to have no windows or I'd better use AppKit for that?