I have (had) a view controller that does a bit of manual layout in a -viewDidLayout override.
This was pretty easy to manage - however since introducing NSGlassEffectView into the view hierarchy I sometimes am getting hit with "Unable to simultaneously satisfy constraints" and Appkit would break a constraint to 'recover.' It appears translatesAutoresizingMaskIntoConstraints is creating some really weird fixed width and height constraints. Here I wasn't doing any autolayout - just add the glass view and set its frame in -viewDidLayout.
At runtime since I do manual layout in -viewDidLayout the frames are fixed and there is no real "error" in my app in practice though I wanted to get rid of the constraint breaking warning being logged because I know Autolayout can be aggressive about 'correctness' who knows if they decide to throw and not catch in the future.
In my perfect world I would probably just prefer a view.doesManualLayout = YES here - the subviews are big containers no labels so localization is not an issue for me. Rather than playing with autoresizing masks to get better translated constraints I decided to set translatesAutoresizingMaskIntoConstraints to NO and make the constraints myself. Now I get hit with the following exception:
"The window has been marked as needing another Layout Window pass, but it has already had more Layout Window passes than there are views in the window"
So this happens because the view which now has constraints -- I adjusted the frame of it one point in -viewDidLayout. My question is - is not legal to make changes in -viewDidLayout - which seems like the AppKit version of -viewDidLayoutSubviews.
In UIKit I always thought it was fine to make changes in -viewDidLayoutSubviews to frames - even if constraints were used - this is a place where you could override things in complex layouts that cannot be easily described in constraints. But in AppKit if you touch certain frames in -viewDidLayout it can now cause this exception (also related: https://developer.apple.com/forums/thread/806471)
I will change the constant of one of the constraints to account for the 1 point adjustment but my question still stands - is it not legal to touch frames in -viewDidLayout when autolayout constraints are used on that subview? It is (or at least was if I remember correctly) permitted to change the layout in -viewDidLayoutSubviews in UIKit but AppKit seems to be more aggressive in its checking for layout correctness).
What about calling -sizeToFit on a control in viewDidLayout or some method that has side effect of invalidating layout in a non obvious way, is doing things like this now 'dangerous?'
Shouldn't AppKit just block the layout from being invalidated from within -viewDidLayout - and leave whatever the layout is as is when viewDidLayout returns (thus making -viewDidLayout a useful place to override layout in the rare cases where you need a sledgehammer?)
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
Description:
I’m encountering an issue where the Apple Watch’s watchOS version is lower than the deployment target specified in my Xcode project.
For example, my Watch device is running watchOS 10.6, but my app’s deployment target is set to watchOS 9.6 or 10.6, and Xcode shows an error stating:
Error: “watchOS version doesn’t match the app’s deployment target.”
Could someone clarify how to properly handle this version mismatch?
Environment:
Xcode 26
iPhone: iOS 18
Apple Watch: watchOS 10.6
Any guidance or best practices would be appreciated.
Switching alternative app icons previously worked in my app and I did not notice when it broke.
However now the completion handler consistently returns this error if feeding with either an existing app icon name or a fictional one.
Is this a regression I should file a bug report for or am I doing something wrong here?
Include all app icon assets is enabled in the target
Below you can see the error, the .icon files placed in the project navigator, my code and the top of the Info.plist
Thank you
Button("Update icon") { UIApplication.shared.setAlternateIconName("appIcon_Heart") { error in
if let error {
print(error)
}
}
}
Error Domain=NSPOSIXErrorDomain Code=35 "Resource temporarily unavailable" UserInfo={_LSFile=LSIconAlertManager.m, _LSLine=113, _LSFunction=-[LSIconAlertManager iconChangeAlertTokenForIdentity:error:]}
Xcode seems to create the correct Info.plist entries.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BGTaskSchedulerPermittedIdentifiers</key>
<array>
<string>newReleasesBackgroundTask</string>
</array>
<key>BuildMachineOSBuild</key>
<string>24G90</string>
<key>CFBundleDevelopmentRegion</key>
<string>de</string>
<key>CFBundleDisplayName</key>
<string>Hörspielzentrale</string>
<key>CFBundleExecutable</key>
<string>Hoerspielzentrale</string>
<key>CFBundleIcons</key>
<dict>
<key>CFBundleAlternateIcons</key>
<dict>
<key>appIcon_Heart</key>
<dict>
<key>CFBundleIconName</key>
<string>appIcon_Heart</string>
</dict>
<key>appIcon_RedNoCircle</key>
<dict>
<key>CFBundleIconName</key>
<string>appIcon_RedNoCircle</string>
</dict>
<key>appIcon_WhiteNoCircle</key>
<dict>
<key>CFBundleIconName</key>
<string>appIcon_WhiteNoCircle</string>
</dict>
</dict>
<key>CFBundlePrimaryIcon</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>AppIcon60x60</string>
</array>
<key>CFBundleIconName</key>
<string>AppIcon</string>
</dict>
</dict>
<key>CFBundleIcons~ipad</key>
<dict>
<key>CFBundleAlternateIcons</key>
<dict>
<key>appIcon_Heart</key>
<dict>
<key>CFBundleIconName</key>
<string>appIcon_Heart</string>
</dict>
<key>appIcon_RedNoCircle</key>
<dict>
<key>CFBundleIconName</key>
<string>appIcon_RedNoCircle</string>
</dict>
<key>appIcon_WhiteNoCircle</key>
<dict>
<key>CFBundleIconName</key>
<string>appIcon_WhiteNoCircle</string>
</dict>
</dict>
<key>CFBundlePrimaryIcon</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>AppIcon60x60</string>
<string>AppIcon76x76</string>
</array>
<key>CFBundleIconName</key>
<string>AppIcon</string>
</dict>
</dict>
Topic:
UI Frameworks
SubTopic:
UIKit
My app (FindAnyFile) provides a Finder-like interface in which it also offers a QuickLook preview command, which invokes
[[QLPreviewPanel sharedPreviewPanel] makeKeyAndOrderFront:nil];
Now, if it shows .abcdp files, it often, but not always, crashes.
This has been happening for many macOS versions, at least since 10.15, up to 26.1. Also, it does not seem to matter which SDK/Xcode I build with, as I used several and all versions lead to the crash. The issue rather appears to be inside the QLplugin for the AB file (ABCardCollectionView etc.).
I am able to trace this crash in Xcode. There are a LOT of errors and warnings coming up, and eventually the qlplugin throws an ObjC exception which in turn brings down my entire app (and here I thought that the XPC system was designed to expressly avoid such crashes).
Possibly significant errors are:
CNAccountCollectionUpdateWatcher 0x6000025cf800: Update event received, but store registration failed. This event will be handled, but the behavior is undefined.
Error using remote object proxy when fetchAnonymousXPCEndpoint: Error Domain=NSCocoaErrorDomain Code=4097 "connection to service named com.apple.telephonyutilities.callservicesdaemon.callstatecontroller" UserInfo={NSDebugDescription=connection to service named com.apple.telephonyutilities.callservicesdaemon.callstatecontroller}
connection to service named com.apple.coreduetd.people … CNPropertyNotFetchedException: A property was not requested when contact was fetched.
I've attached the (mostly) complete console output from such a debug run.
I have also an open bug report regarding this kind of crash (back then I was not able to reproduce it myself): FB15553847
Also, when I "Quick Look" the same file in Finder, I get a "Preview not permitted" for the same items that crash in my app. If I copy the same items to the Desktop, then Finder can QL them and my app doesn't crash when viewing the item on the Desktop. So, the crash only happens with the items inside ~/Library/Application Support/AddressBook/Sources/…/Metadata/.
Now, here is the weirdest part: You might think: So, if the Finder shows "Preview not permitted", then my app trying to view those items is the result of that condition (even if that's not supposed to crash). However: I have a clean 26.1 install (in an Apple ARM VM) where Finder also says "Preview not permitted" for these items in the user's Library/AB/Metadata folder, but my app can QL those items without crashing! Also, I have one user who uses 26.1 and gets the crash with files in the same location. So, the "Preview not permitted" is probably not the cause of this crash, though it's suspicious that a user gets this at all - why can't a user QL the abcdp files in the Metadata folder but when copied to the Desktop, QL works? You'd think that Finder has the necessary entitlements to access the AB, or doesn't it?
Of course, my app has permission enabled under Privacy & Security / Contacts (if it's disabled, then the app can't show anything but will also not crash). And it has the "Address Book" entitlement.
Would be nice if this could be looked into and eventually be fixed.
Alternatively, I'd welcome any suggestions on how to prevent my app from crashing if the qlplugin throws. But if you look at the stack trace you'll see that there's no method of my own app involved where I could insert an exception catcher.
I added code to my previewItemURL delegate method to make sure the NSURL item is readable, and it is, even
Of course, apart from the issue with .abcdp files, the QL operation in my app works flawlessly, i.e. I have never received any other crash reports relating to any other QL plugins.
QuickLook for AddressBook crash messages
Hi,
I am looking to display (in SwiftUI) the Tabview page dots like in the weather app in the toolbar, an important thing is I want to keep page controls by tapping and scrubbing.
Actually, I want to do what's on Apple Design's Page Controls page; here's the link and a photo of what I'd like to do.
Could you help me?
https://developer.apple.com/design/human-interface-guidelines/page-controls
I have an existing iOS app with MapKit. It always shows the current user location with UserAnnotation. But the same isn't true for macOS. I have this sample macOS application in SwiftUI. In the following, the current user location with a large blue dot appears only occasionally. It won't, 19 of 20 times. Why is that? I do have a location privacy key in Info.plist. And the Location checkbox is on under Signing & Capabilities.
import SwiftUI
import MapKit
struct ContentView: View {
@State private var markerItems: [MarkerItem] = [
MarkerItem(name: "Farmers Market 1", lat: 35.681, lon: 139.691),
MarkerItem(name: "Farmers Market 2", lat: 35.685, lon: 139.695),
MarkerItem(name: "Farmers Market 3", lat: 35.689, lon: 139.699)
]
@State private var position: MapCameraPosition = .automatic
var body: some View {
Map(position: $position) {
UserAnnotation()
ForEach(markerItems, id: \.self) { item in
Marker(item.name, coordinate: CLLocationCoordinate2D(latitude: item.lat, longitude: item.lon))
}
}
.mapControlVisibility(.hidden)
.mapStyle(.standard(elevation: .realistic))
.ignoresSafeArea()
}
}
#Preview {
ContentView()
}
struct MarkerItem: Hashable {
let name: String
let lat: Double
let lon: Double
}
Is anyone else getting new warning about menu items with submenus when running on Tahoe? I'm getting big performance problems using my menu as well as seeing these messages and I'm wondering if there's a connection.
My app is faceless with a NSStatusItem with an NSMenu. Specifically it's my own subclass of NSMenu where I have a lot of code to manage the menu's dynamic behavior. This code is directly in the menu subclass instead of in a controller because the app I forked had it this way, a little wacky but I don't see it being a problem. A nib defines the contents of the menu, and it's instantiated manually with code like:
var nibObjects: NSArray? = []
guard let nib = NSNib(nibNamed: "AppMenu", bundle: nil) else { ... }
guard nib.instantiate(withOwner: owner, topLevelObjects: &nibObjects) else { ... }
guard let menu = nibObjects?.compactMap({ $0 as? Self }).first else { ... }
Within that nib.instantiate call I see a warning logged that seems new to Tahoe, before the menu's awakeFromNib is called, that says (edited):
Internal inconsistency in menus - menu <NSMenu: 0x6000034e5340> believes it has <My_StatusItem_App.AppMenu: 0x7f9570c1a440> as a supermenu, but the supermenu does not seem to have any item with that submenu
My_StatusItem_App.AppMenu: 0x7f9570c1a440 is my menu belonging to the NSStatusItem, NSMenu: 0x6000034e5340 is the submenu of one of its menu items.
At a breakpoint in the NSMenu subclass's awakeFromNib I print self and see clear evidence of the warning's incorrectness. Below is a snippet of the console including the full warning, only edited for clarity and brevity. It shows on line 32 menu item with placeholder title "prototype batch item" that indeed has that submenu.
Internal inconsistency in menus - menu <NSMenu: 0x6000034e5340>
Title:
Supermenu: 0x7f9570c1a440 (My StatusItem App), autoenable: YES
Previous menu: 0x0 (None)
Next menu: 0x0 (None)
Items: (
"<NSMenuItem: 0x6000010e4fa0 Do The Thing Again, ke mask='<none>'>",
"<NSMenuItem: 0x6000010e5040 Customize\U2026, ke mask='<none>'>",
"<NSMenuItem: 0x6000010e50e0, ke mask='<none>'>"
) believes it has <My_StatusItem_App.AppMenu: 0x7f9570c1a440>
Title: My StatusItem App
Supermenu: 0x0 (None), autoenable: YES
Previous menu: 0x0 (None)
Next menu: 0x0 (None)
Items: (
) as a supermenu, but the supermenu does not seem to have any item with that submenu
(lldb) po self
<My_StatusItem_App.AppMenu: 0x7f9570c1a440>
Title: My StatusItem App
Supermenu: 0x0 (None), autoenable: YES
Previous menu: 0x0 (None)
Next menu: 0x0 (None)
Items: (
"<NSMenuItem: 0x6000010fd7c0 About My StatusItem App\U2026, ke mask='<none>', action: showAbout:, action image: info.circle>",
"<NSMenuItem: 0x6000010fd860 Show Onboarding Window\U2026, ke mask='Shift', action: showIntro:>",
"<NSMenuItem: 0x6000010fd900 Update Available\U2026, ke mask='<none>', action: installUpdate:, standard image: icloud.and.arrow.down, hidden>",
"<NSMenuItem: 0x6000010e46e0, ke mask='<none>'>",
"<NSMenuItem: 0x6000010e4780 Start The Thing, ke mask='<none>', action: startTheThing:>",
"<NSMenuItem: 0x6000010e4dc0 \U2318-\U232b key detector item, ke mask='<none>', view: <My_StatusItem_App.KeyDetectorView: 0x7f9570c1a010>>",
"<NSMenuItem: 0x6000010e4e60, ke mask='<none>'>",
"<NSMenuItem: 0x6000010e4f00 saved batches heading item, ke mask='<none>', view: <NSView: 0x7f9570b4be10>, hidden>",
"<My_StatusItem_App.BatchMenuItem: 0x6000016e02c0 prototype batch item, ke mask='<none>', action: replaySavedBatch:, submenu: 0x6000034e5340 ()>",
"<NSMenuItem: 0x6000010f7d40, ke mask='<none>'>",
"<My_StatusItem_App.ClipMenuItem: 0x7f956ef14fd0 prototype copy clip item, ke mask='<none>', action: copyClip:>",
"<NSMenuItem: 0x6000010fa620 Settings\U2026, ke='Command-,', action: showSettings:>",
"<NSMenuItem: 0x6000010fa6c0, ke mask='<none>'>",
"<NSMenuItem: 0x6000010fa760 Quit My StatusItem App, ke='Command-Q', action: quit:>"
)
Is this seemingly incorrect inconsistency message harmless? Am I only grasping at straws to think it has some connection to the performance issues with this menu?
The zoom navigation transition with matchedTransitionSource in tabViewBottomAccessory does not work when a Published var in an ObservableObjector Observable gets changed.
Here is an minimal reproducible example with ObservableObject:
import SwiftUI
import Combine
private final class ViewModel: ObservableObject {
@Published var isPresented = false
}
struct ContentView: View {
@Namespace private var namespace
@StateObject private var viewModel = ViewModel()
// @State private var isPresented = false
var body: some View {
TabView {
Button {
viewModel.isPresented = true
} label: {
Text("Start")
}
.tabItem {
Image(systemName: "house")
Text("Home")
}
Text("Search")
.tabItem {
Image(systemName: "magnifyingglass")
Text("Search")
}
Text("Profile")
.tabItem {
Image(systemName: "person")
Text("Profile")
}
}
.sheet(isPresented: $viewModel.isPresented) {
Text("Sheet")
.presentationDragIndicator(.visible)
.navigationTransition(.zoom(sourceID: "tabViewBottomAccessoryTransition", in: namespace))
}
.tabViewBottomAccessory {
Button {
viewModel.isPresented = true
} label: {
Text("BottomAccessory")
}
.matchedTransitionSource(id: "tabViewBottomAccessoryTransition", in: namespace)
}
}
}
However, when using only a State property everything works:
import SwiftUI
import Combine
private final class ViewModel: ObservableObject {
@Published var isPresented = false
}
struct ContentView: View {
@Namespace private var namespace
// @StateObject private var viewModel = ViewModel()
@State private var isPresented = false
var body: some View {
TabView {
Button {
isPresented = true
} label: {
Text("Start")
}
.tabItem {
Image(systemName: "house")
Text("Home")
}
Text("Search")
.tabItem {
Image(systemName: "magnifyingglass")
Text("Search")
}
Text("Profile")
.tabItem {
Image(systemName: "person")
Text("Profile")
}
}
.sheet(isPresented: $isPresented) {
Text("Sheet")
.presentationDragIndicator(.visible)
.navigationTransition(.zoom(sourceID: "tabViewBottomAccessoryTransition", in: namespace))
}
.tabViewBottomAccessory {
Button {
isPresented = true
} label: {
Text("BottomAccessory")
}
.matchedTransitionSource(id: "tabViewBottomAccessoryTransition", in: namespace)
}
}
}
I'm attempting to use WebAuthenticationSession from Authentication Services (https://developer.apple.com/documentation/authenticationservices/webauthenticationsession) in a SwiftUI app on macOS.
According to the docs, it is supported since macOS 13.3 and I'm testing on 26.
I'm deploying the same code to iOS as well, and it works there in a simulator, but I sometimes have to tap the button that triggers the authenticate(…) call more than once.
I've attached a simplified and redacted version of the code below. It works on iOS, but on macOS the authenticate call never returns.
There seems to be very little documentation and discussion about this API and I'm running out of ideas for getting this to work. Is this just a bug that Apple hasn't noticed?
import SwiftUI
import AuthenticationServices
import Combine
struct PreAuthView: View {
@Binding var appState: AppState
@Binding var credentials: Credentials?
@Environment(\.webAuthenticationSession) private var webAuthenticationSession
@State private var plist: String = ""
func authenticate() async {
guard var authUrl = URL(string: "REDACTED") else { return }
guard var tokenUrl = URL(string: "REDACTED") else { return }
let redirectUri = "REDACTED"
let clientId = "REDACTED"
let verifier = "REDACTED"
let challenge = "REDACTED"
authUrl.append(queryItems: [
.init(name: "response_type", value: "code"),
.init(name: "client_id", value: clientId),
.init(name: "redirect_uri", value: redirectUri),
.init(name: "state", value: ""),
.init(name: "code_challenge", value: challenge),
.init(name: "code_challenge_method", value: "S256"),
])
let scheme = "wonderswitcher"
do {
print("Authenticating")
let redirectUrl = try await webAuthenticationSession.authenticate(
using: authUrl,
callback: .https(host: "REDACTED", path: "REDACTED"),
additionalHeaderFields: [:],
)
print("Authenticated?")
print(redirectUrl)
let queryItems = URLComponents(string: redirectUrl.absoluteString)?.queryItems ?? []
let code = queryItems.filter({$0.name == "code"}).first?.value
let session = URLSession(configuration: .ephemeral)
tokenUrl.append(queryItems: [
.init(name: "grant_type", value: "authorization_code"),
.init(name: "code", value: code),
.init(name: "redirect_uri", value: redirectUri),
.init(name: "code_verifier", value: verifier),
.init(name: "client_id", value: clientId),
])
var request = URLRequest(url: tokenUrl)
request.httpMethod = "POST"
let response = try await session.data(for: request)
print(response)
} catch {
return
}
}
var body: some View {
NavigationStack {
VStack(alignment: .leading, spacing: 12) {
Text("This is the pre-auth view.")
HStack {
Button("Log in") {
Task {
await authenticate()
}
}
Spacer()
}
Spacer(minLength: 0)
}
.padding()
.navigationTitle("Pre-Auth")
}
}
}
#Preview {
PreAuthView(appState: .constant(.preAuth), credentials: .constant(nil))
}
Topic:
UI Frameworks
SubTopic:
SwiftUI
I’m running Xcode 26.1.1 (17B100) with deployment target iOS 18.0+, and I’m seeing a consistent and reproducible issue on real devices (iPhone 13 Pro, iPhone 15 Pro):
Problem
The first time the user taps into a TextField or a SwiftUI .searchable field after app launch, the app freezes for 30–45 seconds before the keyboard appears.
During the freeze, the device console floods with:
XPC connection interrupted
Reporter disconnected. { function=sendMessage, reporterID=XXXXXXXXXXXX }
-[RTIInputSystemClient remoteTextInputSessionWithID:performInputOperation:]
perform input operation requires a valid sessionID.
inputModality = Keyboard
customInfoType = UIEmojiSearchOperations
After the keyboard finally appears once, the issue never happens again until the app is force-quit.
This occurs on device
Reproduction Steps
Minimal reproducible setup:
Create a new SwiftUI app.
Add a single TextField or .searchable modifier.
Install Firebase (Firestore or Analytics is enough).
Build and run on device.
Tap the text field immediately after the home screen appears.
Result:
App freezes for 30–45 seconds before keyboard appears, with continuous XPC/RTIInputSystem errors in the logs.
If Firebase is removed, the issue occurs less often, but still happens occasionally.
Even If Firebase initialization is delayed by ~0.5 seconds, the issue is still there.
Question
Is this a known issue with iOS 18 / RTIInputSystem / Xcode 26.1.1, and is there a recommended workaround?
Delaying Firebase initialization avoids the freeze, but this isn’t ideal for production apps with startup authentication requirements.
Any guidance or confirmation would be appreciated.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Any view that is content for the tabViewBottomAccessory API fails to retain its state as of the last couple of 26.1 betas (and RC). The loss of state happens (at least) when the currently selected tab is switched (filed as FB20901325).
Here's code to reproduce the issue:
struct ContentView: View {
@State private var selectedTab = TabSelection.one
enum TabSelection: Hashable {
case one, two
}
var body: some View {
TabView(selection: $selectedTab) {
Tab("One", systemImage: "1.circle", value: .one) {
BugExplanationView()
}
Tab("Two", systemImage: "2.circle", value: .two) {
BugExplanationView()
}
}
.tabViewBottomAccessory {
AccessoryView()
}
}
}
struct AccessoryView: View {
@State private var counter = 0 // This guy's state gets lost (as of iOS 26.1)
var body: some View {
Stepper("Counter: \(counter)", value: $counter)
.padding(.horizontal)
}
}
struct BugExplanationView: View {
var body: some View {
ScrollView {
VStack(alignment: .leading, spacing: 16) {
Text("(1) Manipulate the counter state")
Text("(2) Then switch tabs")
Text("BUG: The counter state gets unexpectedly reset!")
}
.multilineTextAlignment(.leading)
}
}
}
Views placed inside tabViewBottomAccessory that access @Environment values or contain @State properties experience unstable identity, as shown by Self._printChanges(). The identity changes on every structural update to the TabView, even though the view's actual identity should remain stable. This causes unnecessary view recreation and breaks SwiftUI's expected identity and lifecycle behavior.
Environment
Xcode Version 26.2 (17C52)
iOS 26.2 simulator and device
struct ContentView: View {
@State var showMoreTabs = true
struct DemoTab: View {
var body: some View { Text(String(describing: type(of: self))) }
}
var body: some View {
TabView {
Tab("Home", systemImage: "house") { DemoTab() }
Tab("Alerts", systemImage: "bell") { DemoTab() }
if showMoreTabs {
TabSection("Categories") {
Tab("Climate", systemImage: "fan") { DemoTab() }
Tab("Lights", systemImage: "lightbulb") { DemoTab() }
}
}
Tab("Settings", systemImage: "gear") {
List {
Toggle("Show more Tabs", isOn: $showMoreTabs)
}
}
}
.tabViewBottomAccessory {
AccessoryView()
}
.task {
while true {
try? await Task.sleep(for: .seconds(5))
if Task.isCancelled { break }
print("toggling showMoreTabs")
showMoreTabs.toggle()
}
}
.tabBarMinimizeBehavior(.onScrollDown)
}
}
struct AccessoryView: View {
var body: some View {
HStack {
EnvironmentAccess()
WithState()
Stateless()
}
}
}
struct EnvironmentAccess: View {
@Environment(\.tabViewBottomAccessoryPlacement) var placement
var body: some View {
// FIXME: EnvironmentAccess: @self, @identity, _placement changed.
// Identity should be stable
let _ = Self._printChanges()
Text(String(describing: type(of: self))) }
}
struct WithState: View {
@State var int = Int.random(in: 0...100)
var body: some View {
// FIXME: WithState: @self, @identity, _id changed.
// Identity should be stable
let _ = Self._printChanges()
Text(String(describing: type(of: self)))
}
}
struct Stateless: View {
var body: some View {
// Works as expected: Stateless: @self changed.
let _ = Self._printChanges()
Text(String(describing: type(of: self)))
}
}
This bug seems to make accessing TabViewBottomAccessoryPlacement impossible without losing view identity; the demo code is affected by the bug. Accessing a value like @Environment(\.colorScheme) is similarly affected, making visually adapting the contents of the accessory to the TabView content without losing identity challenging if not impossible.
Submitted as FB21627918.
I have been playing around with the new AsyncImage Api in SwiftUI
I am using the initialiser that passes in a closure with the AsyncImagePhase, to view why an image may not load, when I looked at the error that is passed in if the phase is failure, the localised description of the error is "Cancelled" but this is happening before the view is being displayed.
I am loading these images in a list, I imagine I am probably doing something which is causing the system to decide to cancel the loading, but I cannot see what.
Are there any tips to investigate this further?
I have no idea how to do it: on MacOS, in Document.init(configuration: ReadConfiguration) I decode file, and restore objects from data, which in some cases could take a long time. Document isn't fully inited, so I have no access to it. But would like to have a progress bar on screen (easier to wait for done, for now). I know size, progress value, but no idea how to make view from object during init.
I know, this question may be very stupid.
init(configuration: ReadConfiguration) throws {
guard let data = configuration.file.regularFileContents
else {
throw CocoaError(.fileReadCorruptFile)
}
let decoder = JSONDecoder()
let flat = try decoder.decode(FlatDoc.self, from: data)
print ("reverting \(flat.objects.count) objects...")
///This takes time, a lot of time, need progress bar
///Total is `flat.objects.count`, current is `objects.count`
/// `Show me a way to the (next) progress bar!`
revertObjects(from: flat.objects)
print ("...done")
}
update: I defined var flatObjects in Document, and I can convert in .onAppear.
struct TestApp: App {
@State var isLoading = false
...
ContentView(document: file.$document)
.onAppear {
isLoading = true
Task {file.document.revertObjects()}
isLoading = false
}
if isLoading {
ProgressView()
}
...
}
But progress bar never shows, only rainbow ball
All system colors are displayed incorrectly on the popover view.
Those are the same views present as a popover in light and dark mode.
And those are the same views present as modal.
And there is also a problem that when the popover is presented, switching to dark/light mode will not change the appearance. That affected all system apps.
The following screenshot is already in dark mode.
All those problem are occured on iOS 26 beta 3.
Crash in UIKeyboardStateManager when repeatedly switching text input focus in WKWebView (hybrid app)
We’re building a hybrid iOS app using Angular (web) rendered inside a WKWebView, hosted by a native Swift app.
Recently, we encountered a crash related to UIKeyboardStateManager in UIKit when switching between text inputs continuously within an Angular screen.
Scenario
The screen contains several text input fields.
A “Next” button focuses the next input field programmatically.
After about 61 continuous input field changes, the app crashes.
It seems like this may be related to UIKit’s internal keyboard management while switching focus rapidly inside a WebView.
crash stack:
Crashed: com.apple.main-thread
0 WebKit 0xfbdad0 <redacted> + 236
1 UIKitCore 0x10b0548 -[UITextInteractionSelectableInputDelegate _moveToStartOfLine:withHistory:] + 96
2 UIKitCore 0xd0fb38 -[UIKBInputDelegateManager _moveToStartOfLine:withHistory:] + 188
3 UIKitCore 0xa16174 __158-[_UIKeyboardStateManager handleMoveCursorToStartOfLine:beforePublicKeyCommands:testOnly:savedHistory:force:canHandleSelectableInputDelegateCommand:keyEvent:]_block_invoke + 52
4 UIKitCore 0xa36ae4 -[_UIKeyboardStateManager performBlockWithTextInputChangesIgnoredForNonMacOS:] + 48
5 UIKitCore 0xa160f0 -[_UIKeyboardStateManager handleMoveCursorToStartOfLine:beforePublicKeyCommands:testOnly:savedHistory:force:canHandleSelectableInputDelegateCommand:keyEvent:] + 440
6 UIKitCore 0xa07010 -[_UIKeyboardStateManager handleKeyCommand:repeatOkay:options:] + 5760
7 UIKitCore 0xa2fb64 -[_UIKeyboardStateManager _handleKeyCommandCommon:options:] + 76
8 UIKitCore 0xa2fb08 -[_UIKeyboardStateManager _handleKeyCommand:] + 20
9 UIKitCore 0xa30684 -[_UIKeyboardStateManager handleKeyEvent:executionContext:] + 2464
10 UIKitCore 0xa2f95c __42-[_UIKeyboardStateManager handleKeyEvent:]_block_invoke + 40
11 UIKitCore 0x4b9460 -[UIKeyboardTaskEntry execute:] + 208
12 UIKitCore 0x4b92f4 -[UIKeyboardTaskQueue continueExecutionOnMainThread] + 356
13 UIKitCore 0x4b8be0 -[UIKeyboardTaskQueue addTask:breadcrumb:] + 120
14 UIKitCore 0x4a9ed0 -[_UIKeyboardStateManager _setupDelegate:delegateSame:hardwareKeyboardStateChanged:endingInputSessionIdentifier:force:delayEndInputSession:] + 3388
15 UIKitCore 0xfa290 -[_UIKeyboardStateManager setDelegate:force:delayEndInputSession:] + 628
16 UIKitCore 0xf617c -[UIKeyboardSceneDelegate _reloadInputViewsForKeyWindowSceneResponder:force:fromBecomeFirstResponder:] + 1140
17 UIKitCore 0xf5c88 -[UIKeyboardSceneDelegate _reloadInputViewsForResponder:force:fromBecomeFirstResponder:] + 88
18 UIKitCore 0x4fe4ac -[UIResponder(UIResponderInputViewAdditions) reloadInputViews] + 84
19 WebKit 0xfbe708 <redacted> + 100
20 WebKit 0xfbf594 <redacted> + 340
21 WebKit 0x8a33d8 <redacted> + 32
22 WebKit 0x8cee04 <redacted> + 144
23 WebKit 0x1c83f0 <redacted> + 22692
24 WebKit 0x73f40 <redacted> + 264
25 WebKit 0x162c7c <redacted> + 40
26 WebKit 0x1623b4 <redacted> + 1608
27 WebKit 0x73298 <redacted> + 268
28 WebKit 0x72e48 <redacted> + 660
29 JavaScriptCore 0xdb00 WTF::RunLoop::performWork() + 524
30 JavaScriptCore 0xd744 WTF::RunLoop::performWork(void*) + 36
31 CoreFoundation 0xf92c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28
32 CoreFoundation 0xf744 __CFRunLoopDoSource0 + 172
33 CoreFoundation 0xf5a0 __CFRunLoopDoSources0 + 232
34 CoreFoundation 0xff20 __CFRunLoopRun + 840
35 CoreFoundation 0x11adc CFRunLoopRunSpecific + 572
36 GraphicsServices 0x1454 GSEventRunModal + 168
37 UIKitCore 0x135274 -[UIApplication _run] + 816
38 UIKitCore 0x100a28 UIApplicationMain + 336
39 APP1 0xa2ed0 main + 21 (AppDelegate.swift:21)
40 ??? 0x1aa889f08 (シンボルが不足しています)
From reviewing the crash log, it appears that the crash occurs inside UIKeyboardStateManager while handling keyboard or cursor updates.
Questions
Has anyone seen this specific crash pattern involving UIKeyboardStateManager?
Are there known UIKit or WebKit bugs related to UIKeyboardStateManager when continuously changing focus between text fields (especially in WKWebView)?
Any insights or workarounds would be greatly appreciated.
Thanks!
Do you know if there is a work around to animate the reorder of a table without generating ghost rows?
here is the code:
var id = UUID()
var name: String
var value: Int
}
struct ContentView: View {
@State var selectedNumber: UUID?
@State var sortedBy: [KeyPathComparator<MyNumbers>] = [KeyPathComparator(\.name, order: .reverse)]
@State var numbers: [MyNumbers] = {
var numbersArray = [MyNumbers]()
for i in 0..<100 {
numbersArray.append(MyNumbers(name: "\(i)", value: i))
}
return numbersArray
}()
var body: some View {
Table(numbers, selection: $selectedNumber, sortOrder: $sortedBy) {
TableColumn("names", value: \.name){ number in
Text(number.name)
}
TableColumn("names", value: \.name){ number in
Text(number.name)
}
}.onChange(of: sortedBy) { oldValue, newValue in
withAnimation {
numbers.sort(using: newValue)
}
}
}
}
it generates ghost rows when the top row is selected and reorders twice, as you can see in the screenshot, the first six rows has two labels overlapped.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Our app works fine on iOS 26 on other platforms but on iphone17, the text on the popovers is so light it is unreadable when the device is in Light mode. Is anyone else having this issue and if so, do you have any recommendations?
Topic:
UI Frameworks
SubTopic:
General
Hello, I've a question about performance when trying to render lots of items coming from SwiftData via a @Query on a SwiftUI List. Here's my setup:
// Item.swift:
@Model final class Item: Identifiable {
var timestamp: Date
var isOptionA: Bool
init() {
self.timestamp = Date()
self.isOptionA = Bool.random()
}
}
// Menu.swift
enum Menu: String, CaseIterable, Hashable, Identifiable {
var id: String { rawValue }
case optionA
case optionB
case all
var predicate: Predicate<Item> {
switch self {
case .optionA: return #Predicate { $0.isOptionA }
case .optionB: return #Predicate { !$0.isOptionA }
case .all: return #Predicate { _ in true }
}
}
}
// SlowData.swift
@main
struct SlowDataApp: App {
var sharedModelContainer: ModelContainer = {
let schema = Schema([Item.self])
let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false)
return try! ModelContainer(for: schema, configurations: [modelConfiguration])
}()
var body: some Scene {
WindowGroup {
ContentView()
}
.modelContainer(sharedModelContainer)
}
}
// ContentView.swift
struct ContentView: View {
@Environment(\.modelContext) private var modelContext
@State var selection: Menu? = .optionA
var body: some View {
NavigationSplitView {
List(Menu.allCases, selection: $selection) { menu in
Text(menu.rawValue).tag(menu)
}
} detail: {
DemoListView(selectedMenu: $selection)
}.onAppear {
// Do this just once
// (0..<15_000).forEach { index in
// let item = Item()
// modelContext.insert(item)
// }
}
}
}
// DemoListView.swift
struct DemoListView: View {
@Binding var selectedMenu: Menu?
@Query private var items: [Item]
init(selectedMenu: Binding<Menu?>) {
self._selectedMenu = selectedMenu
self._items = Query(filter: selectedMenu.wrappedValue?.predicate,
sort: \.timestamp)
}
var body: some View {
// Option 1: touching `items` = slow!
List(items) { item in
Text(item.timestamp.description)
}
// Option 2: Not touching `items` = fast!
// List {
// Text("Not accessing `items` here")
// }
.navigationTitle(selectedMenu?.rawValue ?? "N/A")
}
}
When I use Option 1 on DemoListView, there's a noticeable delay on the navigation. If I use Option 2, there's none. This happens both on Debug builds and Release builds, just FYI because on Xcode 16 Debug builds seem to be slower than expected: https://indieweb.social/@curtclifton/113273571392595819
I've profiled it and the SwiftData fetches seem blazing fast, the Hang occurs when accessing the items property from the List. Is there anything I'm overlooking or it's just as fast as it can be right now?
I'm working on a watchOS app using SwiftUI that updates its UI based on regular, time-driven logic. On a real Apple Watch, after the app has been running for ~1 minute, the device enters Always-On / power-saving display mode (screen dimmed, wrist down). From that point on, SwiftUI UI updates become noticeably delayed. The underlying logic continues to run correctly, but the UI only redraws sporadically and often "catches up" once the screen becomes fully active again. The app is running in workout mode, which keeps it alive and maintains WatchConnectivity, but this does not prevent UI redraw throttling. Below is a minimal reproducible example that demonstrates the issue.
PlaybackModel.swift
import SwiftUI
@MainActor
final class PlaybackModel: ObservableObject {
@Published var beat: Int = 0
private var timer: Timer?
func start() {
timer?.invalidate()
timer = Timer.scheduledTimer(withTimeInterval: 0.5, repeats: true) { _ in
Task { @MainActor in
self.beat += 1
}
}
}
func stop() {
timer?.invalidate()
}
}
ContentView.swift (watchOS)
import SwiftUI
struct ContentView: View {
@StateObject private var model = PlaybackModel()
var body: some View {
VStack {
Text("Beat: \(model.beat)")
.font(.largeTitle)
}
.onAppear {
model.start()
}
.onDisappear {
model.stop()
}
}
}
Observed Behavior
• The beat value continues to increase reliably.
• After the watch enters Always-On / power-saving mode, SwiftUI redraws are delayed or skipped.
• When the screen becomes fully active again, the UI catches up.
Questions:
• Is this UI redraw throttling in Always-On / power-saving mode an unavoidable system limitation on watchOS?
• Is there any supported way to keep consistent SwiftUI update frequency while the app is visible but dimmed?