Search results for

“swiftui”

17,495 results found

Post

Replies

Boosts

Views

Activity

XPC Communication between Editor app and user-compiled code
Hello! I'm trying to implement an editor app (macOS) that allows the user to write code, which will be compiled and executed, showing the result in the editor window. Imagine it like SwiftUI previews, but the graphic output is created with Metal, not SwiftUI. I found that IOSurface can be used to share that kind of data over XPC, so I would not have to rely on the private NSRemoteView. However, I'm confused if it is, at all, possible for my editor app to connect to an XPC Service, that was NOT bundled with it (but compiled by it at runtime). I succeeded to launch an XPC service defined as: Label com.myteam.myproject.service MachServices com.myteam.myproject.service Program /Path/to/service/run_my_service.sh But the call to let connection = NSXPCConnection(machServiceName: com.myteam.myproject.service) let proxy = connection.remoteObjectProxyWithErrorHandler { error in continuation.resume(throwing: error) } as? MyServiceProtocol fails with The connection to service named com.myteam.m
6
0
1.5k
May ’26
Reply to CLLocationManager permission prompt never appears in Swift Playground
Solved! Thank you to everyone who responded. The issue: The location permission prompt never appeared when requestWhenInUseAuthorization() was called from within a SwiftUI sheet (modal view). iOS silently ignores permission requests made from inside sheets. The fix: Move the permission request to the parent view’s .onAppear modifier — before any sheet is presented. The LocationManager is created as a @StateObject in the main ContentView, requestPermission() is called in ContentView.onAppear, and the LocationManager instance is passed into the sheet view as an @ObservedObject. Key points: • The Core Location When in Use capability must be enabled in Swift Playgrounds app settings • Use @StateObject in the parent view, @ObservedObject in the sheet • Call requestWhenInUseAuthorization() from the main view, not from inside a sheet • startUpdatingLocation() can still be called from within the sheet’s .onAppear Hope this helps someone else!
May ’26
tabViewBottomAccessory does not inherit tab bar vibrancy / foregroundStyle behavior
Hi, I’m experimenting with the new tabViewBottomAccessory API and I’m running into an inconsistency with how colors are handled compared to the native tab bar items. Context When using a TabView, the system tab bar automatically adapts its foreground color (icons and labels) based on the background content (light/dark, images, etc.). This is the expected “vibrancy” behavior. However, when adding content via .tabViewBottomAccessory, the foreground color does not seem to follow the same logic. Minimal example : import SwiftUI struct ContentView: View { var body: some View { TabView { Tab(Home, systemImage: house) { Text(Home) .frame(maxWidth: .infinity, maxHeight: .infinity) .ignoresSafeArea() } Tab(New, systemImage: squareshape.split.2x2) { Text(New) .frame(maxWidth: .infinity, maxHeight: .infinity) .foregroundStyle(.white) .background(Color.black) .ignoresSafeArea() } } .tabViewBottomAccessory { HStack { Image(systemName: command.square) Text(Message test) Spacer() Image(systemName: play.fill) } .pad
Topic: UI Frameworks SubTopic: SwiftUI
0
0
131
May ’26
TelephonyMessagingKit drops first SMS at cold launch — race between client XPC handler registration and server pending flush
Hi all, I'm the developer of OV Message, an end-to-end encrypted SMS messaging app already shipped on Google Play (Android, where it natively encrypts SMS content). The iOS port aims to be the default carrier-messaging app, handling SMS, MMS, and RCS through TelephonyMessagingKit with the com.apple.developer.carrier-messaging-app entitlement under the EU programme. While testing the cold-launch flow on iOS 26.x, I've hit a reproducible bug that silently drops the first SMS/MMS/RCS that wakes the app, and I'd like to confirm whether other devs working with this API see the same. The bug When a default carrier-messaging app is force-killed and a message arrives, iOS correctly: Routes the message via CommCenter (IMS in my case — SFR France) Wakes the app in background (state = .background at didFinishLaunchingWithOptions) Acquires a TelephonyMessaging runningboard assertion on the app But CommCenter then pushes the pending message via XPC before the client TMK library has finished registering its messageHandlers
7
0
1.2k
May ’26
Reply to Charts performance issue
Hi everyone, I observe similar performance issue. They performance is degraded when the x axis domain is enlarged. I add 5 bars per day, and around 150 days there is a visible jitter and tearing while dragging. I've tried various techniques to improve it such as large xAxis and displaying events only around the scroll position, however as noted above using it lowers the performance. I've also tried prepending and apending days, without having a large x axis domain, but this makes the scroll position jump. Here is another code sample. import Charts import SwiftUI struct PerformanceBarChart: View { struct DataPoint: Identifiable { let id = UUID() let date: Date let x: Int let yStart: Date let yEnd: Date let category: String } private var today = Date.now.startOfDay() @State private var data: [DataPoint] = [] @State private var scrollPosition: Date = Date.now @State private var loading = false @State var xAxisDomain: ClosedRange = Date.now...Date.now private let calendar = Calendar.autoupdatingCurrent p
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’26
SwiftUI TabView(.sidebarAdaptable) does not reliably animate content resize when switching between sidebar and top tab bar on iPad
Hi everyone, I’m building an iPad app in SwiftUI using the adaptive tab navigation pattern: Tab(value: .overview) { OverviewView() } label: { Label(Overview, systemImage: archivebox) } Tab(value: .gallery) { GalleryView() } label: { Label(Gallery, systemImage: shippingbox) } Tab(value: .canvas) { CanvasView() } label: { Label(Canvas, systemImage: rectangle) } Tab(value: .record) { recordView } label: { Label(Record, systemImage: plus) } } .tabViewStyle(.sidebarAdaptable) .tabViewCustomization($tabCustomization) The issue is that when the adaptive tab bar switches between the sidebar placement and the top bar placement on iPad, the content area resize animation is unreliable. The system navigation chrome changes correctly, but some tab contents jump directly to their final width instead of smoothly animating with the sidebar/top bar transition. Interestingly, one of my record views appears to animate consistently, so it seems the system transition itself is possible, but some view hierarchy or navigat
Topic: UI Frameworks SubTopic: SwiftUI
0
0
154
May ’26
Reply to SwiftUI Text rendering with too small height / one line missing causing unexpected text truncation on iPhone devices
I can always reproduce this with any iPhone device or simulator with 2556x1179 screen for iOS 18.6, 26.4, and 26.5, but not on iOS 17.5. I didn't test other iOS versions so far. On my iPhone 15 device I have now reproduced again with 26.4.2 and earlier 26.4.1 I believe. macOS 26.4.1 (25E253) Xcode 26.5.0 beta 2 and beta 3 or Xcode 26.4.0 (17E192) I'm not sure what variable is different in your setup. In our main app this is part of an UICollectionView To confirm, you see the same result outside of a UIViewRepresentable as well? To make this more clear: Our main app is a bigger UICollectionViewController with UICollectionViewCell's with SwiftUI hosted content configuration. It happens here on the same devices (screen size) and horizontal padding of 20. No dynamic type involved here, because we have our own Typography system (creating Font and UIFont) with fixed font sizes and line heights. We now will ship a UILabel embedded in the same cell via UIViewRepresentable, which doesn't have this bug. So UIK
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’26
App Review Guidelines 2.5.1 / 2.5.2 — official guidance on screen capture protection for sensitive content
Hi all, We are developing an iOS app that includes private user-to-user chats, commercial offer details with monetary value, and customer identification data. In line with OWASP MASVS-PLATFORM-3 requirements regarding unintentional sensitive data exposure, we need to protect these specific screens from screenshots and screen recording. We have carefully reviewed the relevant App Review Guidelines (2.5.1 on public APIs, 2.5.2 on self-contained bundles, 5.1.1 on privacy) and the related Human Interface Guidelines. From this analysis we have observed the following: iOS does not expose a public API to globally disable screen capture (no direct equivalent of Android's FLAG_SECURE). The SwiftUI .privacySensitive() modifier is effective for Lock Screen widgets and Always-On Display, but it does not appear to prevent screenshots or screen recording of an app's main UI while in the foreground. A number of widely distributed App Store apps (banking, authenticator, secure messaging) implement some form of scree
5
0
1.4k
Apr ’26
Reply to ToolbarItemGroup With Palette Style Cannot Present a View Controller While the Context Menu Is Visible
Thanks for your post and answering my questions as well as providing more information that I didn’t had before. More and more looks like a UIKit timing issue, I know you do not think so, but give me a chance. When I look at the error is the common error when a View has not finished and I try to load a new one. Wrapping SwiftUI views in UIHostingController and managing the navigation stack via UINavigationController is the standard migration path for established UIKit apps. SwiftUI is designed to interoperate smoothly with this architecture, so you shouldn't be forced to migrate your entire presentation layer to SwiftUI just to get a context menu to dismiss properly. The behavior you are describing—where a menu presented from a ToolbarItemGroup refuses to dismiss upon selection unless a SwiftUI-native presentation modifier (like .sheet) is triggered sounds like SwiftUI bridges its menu lifecycle with the host environment. A button tap inside a menu should dismiss th
Topic: UI Frameworks SubTopic: UIKit Tags:
Apr ’26
Reply to ToolbarItemGroup With Palette Style Cannot Present a View Controller While the Context Menu Is Visible
@DTS Engineer Thank you for your response Albert, Is it timing the issue? I don't think it is a timing issue because even if I don't trigger a navigation, basically just removing the action code for the Edit button, nothing happens, the system doesn't dismiss the context menu when an option is selected automatically. If that would happen I could try to get away with a short delay before presenting. (not ideal though) you should avoid calling UIKit's present() manually from a SwiftUI button action Thanks for the suggestion, unfortunately my whole project still relies on UINavigationControllers and UIHostingControllers to manage navigation and presentation, but I want to revisit migrating to full SwiftUI approach since its support has improved greatly with the introduction of NavigationStack. I tried the following just to see what happens: Since the context menu doesn't disappear when an option is tapped and no action is triggered, I tried updating a string property annotated with @State and i
Topic: UI Frameworks SubTopic: UIKit Tags:
Apr ’26
How can I reliably get the final restored window size on macOS when onAppear / viewDidAppear fires too early?
I’m running into a macOS window restoration behavior issue where viewDidAppear (AppKit) or onAppear (SwiftUI) fires before the window’s final restored size is applied. AppKit example class MyViewController: NSViewController { override func viewDidLayout() { print(viewDidLayout: (view.bounds.size)) } override func viewDidAppear() { print(viewDidAppear: (view.bounds.size)) } } Logs on launch: viewDidAppear: (480.0, 270.0) viewDidLayout: (480.0, 270.0) viewDidLayout: (556.0, 476.0) viewDidLayout: (556.0, 476.0) The correct restored size is (556.0, 476.0), but viewDidAppear initially reports the old default size (480.0, 270.0). SwiftUI equivalent struct MyView: View { var body: some View { GeometryReader { geo in VStack {} .onAppear { print(onAppear: (geo.size)) } .onChange(of: geo.size) { print(onChange: (geo.size)) } } } } Logs on launch: onAppear: (900.0, 450.0) onChange: (680.0, 658.0) Problem I need to run some setup code: Only once After the view/window has its correct restored size Withou
3
0
736
Apr ’26
CLLocationManager permission prompt never appears in Swift Playground
I am building a Swift Playgrounds App project on iPad running iPadOS 26.0.1 using the latest version of Swift Playgrounds. I need to access Core Location for a plant location logging app. What I have done: • Created an App project (not a Playground) in Swift Playgrounds • Enabled ‘Core Location When in Use’ in the app capabilities (accessed by tapping the app name) • Implemented a CLLocationManager with CLLocationManagerDelegate • Called manager.requestWhenInUseAuthorization() from .onAppear in a SwiftUI view • Called manager.startUpdatingLocation() immediately after The problem: The location permission prompt never appears when the app runs. The app does not appear in Settings → Privacy & Security → Location Services at all. There are no error messages or crashes — the app simply never requests location access. What I have ruled out: • The capability IS enabled in Swift Playgrounds app settings • The app runs without errors otherwise • This is an App project, not a classic Playground, so it shou
3
0
930
Apr ’26
Reply to SwiftUI TextField.accessibilityIdentifier is not propagated to the underlying UITextField instance.
Hello @Divyashruti, Thank you for your question. SwiftUI views do not necessarily map 1-to-1 to UIKit UIView classes, and so you should not rely on framework calls based on that assumption. Couldn't you stick to using SwiftUI modifiers, such as onChange(of:initial:_:), or use custom bindings? Hoping this helps, Richard Yeh  Developer Technical Support
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’26
Reply to ToolbarItemGroup With Palette Style Cannot Present a View Controller While the Context Menu Is Visible
Thanks for the post, and great UI in my opinion. Hope as many SwiftUI people jump into this thread but I think the issue is because you are using UIKit. I think based on the error message, the error you are seeing is a UIKit presentation issue when a UI isn’t finished so looks like .palette control group style on iOS is backed by UIKit's context menu system (UIContextMenuInteraction). https://developer.apple.com/documentation/uikit/uicontextmenuinteraction When the menu is open, a private view controller (_UIContextMenuActionsOnlyViewController) is actively being presented. I think the issue here is as UIKit strictly enforces that a UIViewController can only present one view controller at a time, but you call to present(...) fails because the underlying navigation controller is still busy presenting the context menu? Is it timing the issue? If possible, you should avoid calling UIKit's present() manually from a SwiftUI button action. Instead, update a @State or @Published property in your vi
Topic: UI Frameworks SubTopic: UIKit Tags:
Apr ’26
XPC Communication between Editor app and user-compiled code
Hello! I'm trying to implement an editor app (macOS) that allows the user to write code, which will be compiled and executed, showing the result in the editor window. Imagine it like SwiftUI previews, but the graphic output is created with Metal, not SwiftUI. I found that IOSurface can be used to share that kind of data over XPC, so I would not have to rely on the private NSRemoteView. However, I'm confused if it is, at all, possible for my editor app to connect to an XPC Service, that was NOT bundled with it (but compiled by it at runtime). I succeeded to launch an XPC service defined as: Label com.myteam.myproject.service MachServices com.myteam.myproject.service Program /Path/to/service/run_my_service.sh But the call to let connection = NSXPCConnection(machServiceName: com.myteam.myproject.service) let proxy = connection.remoteObjectProxyWithErrorHandler { error in continuation.resume(throwing: error) } as? MyServiceProtocol fails with The connection to service named com.myteam.m
Replies
6
Boosts
0
Views
1.5k
Activity
May ’26
Reply to CLLocationManager permission prompt never appears in Swift Playground
Solved! Thank you to everyone who responded. The issue: The location permission prompt never appeared when requestWhenInUseAuthorization() was called from within a SwiftUI sheet (modal view). iOS silently ignores permission requests made from inside sheets. The fix: Move the permission request to the parent view’s .onAppear modifier — before any sheet is presented. The LocationManager is created as a @StateObject in the main ContentView, requestPermission() is called in ContentView.onAppear, and the LocationManager instance is passed into the sheet view as an @ObservedObject. Key points: • The Core Location When in Use capability must be enabled in Swift Playgrounds app settings • Use @StateObject in the parent view, @ObservedObject in the sheet • Call requestWhenInUseAuthorization() from the main view, not from inside a sheet • startUpdatingLocation() can still be called from within the sheet’s .onAppear Hope this helps someone else!
Replies
Boosts
Views
Activity
May ’26
tabViewBottomAccessory does not inherit tab bar vibrancy / foregroundStyle behavior
Hi, I’m experimenting with the new tabViewBottomAccessory API and I’m running into an inconsistency with how colors are handled compared to the native tab bar items. Context When using a TabView, the system tab bar automatically adapts its foreground color (icons and labels) based on the background content (light/dark, images, etc.). This is the expected “vibrancy” behavior. However, when adding content via .tabViewBottomAccessory, the foreground color does not seem to follow the same logic. Minimal example : import SwiftUI struct ContentView: View { var body: some View { TabView { Tab(Home, systemImage: house) { Text(Home) .frame(maxWidth: .infinity, maxHeight: .infinity) .ignoresSafeArea() } Tab(New, systemImage: squareshape.split.2x2) { Text(New) .frame(maxWidth: .infinity, maxHeight: .infinity) .foregroundStyle(.white) .background(Color.black) .ignoresSafeArea() } } .tabViewBottomAccessory { HStack { Image(systemName: command.square) Text(Message test) Spacer() Image(systemName: play.fill) } .pad
Topic: UI Frameworks SubTopic: SwiftUI
Replies
0
Boosts
0
Views
131
Activity
May ’26
TelephonyMessagingKit drops first SMS at cold launch — race between client XPC handler registration and server pending flush
Hi all, I'm the developer of OV Message, an end-to-end encrypted SMS messaging app already shipped on Google Play (Android, where it natively encrypts SMS content). The iOS port aims to be the default carrier-messaging app, handling SMS, MMS, and RCS through TelephonyMessagingKit with the com.apple.developer.carrier-messaging-app entitlement under the EU programme. While testing the cold-launch flow on iOS 26.x, I've hit a reproducible bug that silently drops the first SMS/MMS/RCS that wakes the app, and I'd like to confirm whether other devs working with this API see the same. The bug When a default carrier-messaging app is force-killed and a message arrives, iOS correctly: Routes the message via CommCenter (IMS in my case — SFR France) Wakes the app in background (state = .background at didFinishLaunchingWithOptions) Acquires a TelephonyMessaging runningboard assertion on the app But CommCenter then pushes the pending message via XPC before the client TMK library has finished registering its messageHandlers
Replies
7
Boosts
0
Views
1.2k
Activity
May ’26
Reply to Charts performance issue
Hi everyone, I observe similar performance issue. They performance is degraded when the x axis domain is enlarged. I add 5 bars per day, and around 150 days there is a visible jitter and tearing while dragging. I've tried various techniques to improve it such as large xAxis and displaying events only around the scroll position, however as noted above using it lowers the performance. I've also tried prepending and apending days, without having a large x axis domain, but this makes the scroll position jump. Here is another code sample. import Charts import SwiftUI struct PerformanceBarChart: View { struct DataPoint: Identifiable { let id = UUID() let date: Date let x: Int let yStart: Date let yEnd: Date let category: String } private var today = Date.now.startOfDay() @State private var data: [DataPoint] = [] @State private var scrollPosition: Date = Date.now @State private var loading = false @State var xAxisDomain: ClosedRange = Date.now...Date.now private let calendar = Calendar.autoupdatingCurrent p
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
May ’26
Reply to SwiftUI Text rendering with too small height / one line missing causing unexpected text truncation on iPhone devices
Another reason we assume this is a system-level SwiftUI bug affecting German is this screenshot from another colleague, showing an iMessage. When copying the message, the text is complete in the clipboard: Der Schulleiter Raum für Lehrkräfte. Eine Knallerschule!
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
May ’26
SwiftUI TabView(.sidebarAdaptable) does not reliably animate content resize when switching between sidebar and top tab bar on iPad
Hi everyone, I’m building an iPad app in SwiftUI using the adaptive tab navigation pattern: Tab(value: .overview) { OverviewView() } label: { Label(Overview, systemImage: archivebox) } Tab(value: .gallery) { GalleryView() } label: { Label(Gallery, systemImage: shippingbox) } Tab(value: .canvas) { CanvasView() } label: { Label(Canvas, systemImage: rectangle) } Tab(value: .record) { recordView } label: { Label(Record, systemImage: plus) } } .tabViewStyle(.sidebarAdaptable) .tabViewCustomization($tabCustomization) The issue is that when the adaptive tab bar switches between the sidebar placement and the top bar placement on iPad, the content area resize animation is unreliable. The system navigation chrome changes correctly, but some tab contents jump directly to their final width instead of smoothly animating with the sidebar/top bar transition. Interestingly, one of my record views appears to animate consistently, so it seems the system transition itself is possible, but some view hierarchy or navigat
Topic: UI Frameworks SubTopic: SwiftUI
Replies
0
Boosts
0
Views
154
Activity
May ’26
Reply to SwiftUI Text rendering with too small height / one line missing causing unexpected text truncation on iPhone devices
I can always reproduce this with any iPhone device or simulator with 2556x1179 screen for iOS 18.6, 26.4, and 26.5, but not on iOS 17.5. I didn't test other iOS versions so far. On my iPhone 15 device I have now reproduced again with 26.4.2 and earlier 26.4.1 I believe. macOS 26.4.1 (25E253) Xcode 26.5.0 beta 2 and beta 3 or Xcode 26.4.0 (17E192) I'm not sure what variable is different in your setup. In our main app this is part of an UICollectionView To confirm, you see the same result outside of a UIViewRepresentable as well? To make this more clear: Our main app is a bigger UICollectionViewController with UICollectionViewCell's with SwiftUI hosted content configuration. It happens here on the same devices (screen size) and horizontal padding of 20. No dynamic type involved here, because we have our own Typography system (creating Font and UIFont) with fixed font sizes and line heights. We now will ship a UILabel embedded in the same cell via UIViewRepresentable, which doesn't have this bug. So UIK
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
May ’26
App Review Guidelines 2.5.1 / 2.5.2 — official guidance on screen capture protection for sensitive content
Hi all, We are developing an iOS app that includes private user-to-user chats, commercial offer details with monetary value, and customer identification data. In line with OWASP MASVS-PLATFORM-3 requirements regarding unintentional sensitive data exposure, we need to protect these specific screens from screenshots and screen recording. We have carefully reviewed the relevant App Review Guidelines (2.5.1 on public APIs, 2.5.2 on self-contained bundles, 5.1.1 on privacy) and the related Human Interface Guidelines. From this analysis we have observed the following: iOS does not expose a public API to globally disable screen capture (no direct equivalent of Android's FLAG_SECURE). The SwiftUI .privacySensitive() modifier is effective for Lock Screen widgets and Always-On Display, but it does not appear to prevent screenshots or screen recording of an app's main UI while in the foreground. A number of widely distributed App Store apps (banking, authenticator, secure messaging) implement some form of scree
Replies
5
Boosts
0
Views
1.4k
Activity
Apr ’26
Reply to ToolbarItemGroup With Palette Style Cannot Present a View Controller While the Context Menu Is Visible
Thanks for your post and answering my questions as well as providing more information that I didn’t had before. More and more looks like a UIKit timing issue, I know you do not think so, but give me a chance. When I look at the error is the common error when a View has not finished and I try to load a new one. Wrapping SwiftUI views in UIHostingController and managing the navigation stack via UINavigationController is the standard migration path for established UIKit apps. SwiftUI is designed to interoperate smoothly with this architecture, so you shouldn't be forced to migrate your entire presentation layer to SwiftUI just to get a context menu to dismiss properly. The behavior you are describing—where a menu presented from a ToolbarItemGroup refuses to dismiss upon selection unless a SwiftUI-native presentation modifier (like .sheet) is triggered sounds like SwiftUI bridges its menu lifecycle with the host environment. A button tap inside a menu should dismiss th
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Apr ’26
Reply to ToolbarItemGroup With Palette Style Cannot Present a View Controller While the Context Menu Is Visible
@DTS Engineer Thank you for your response Albert, Is it timing the issue? I don't think it is a timing issue because even if I don't trigger a navigation, basically just removing the action code for the Edit button, nothing happens, the system doesn't dismiss the context menu when an option is selected automatically. If that would happen I could try to get away with a short delay before presenting. (not ideal though) you should avoid calling UIKit's present() manually from a SwiftUI button action Thanks for the suggestion, unfortunately my whole project still relies on UINavigationControllers and UIHostingControllers to manage navigation and presentation, but I want to revisit migrating to full SwiftUI approach since its support has improved greatly with the introduction of NavigationStack. I tried the following just to see what happens: Since the context menu doesn't disappear when an option is tapped and no action is triggered, I tried updating a string property annotated with @State and i
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Apr ’26
How can I reliably get the final restored window size on macOS when onAppear / viewDidAppear fires too early?
I’m running into a macOS window restoration behavior issue where viewDidAppear (AppKit) or onAppear (SwiftUI) fires before the window’s final restored size is applied. AppKit example class MyViewController: NSViewController { override func viewDidLayout() { print(viewDidLayout: (view.bounds.size)) } override func viewDidAppear() { print(viewDidAppear: (view.bounds.size)) } } Logs on launch: viewDidAppear: (480.0, 270.0) viewDidLayout: (480.0, 270.0) viewDidLayout: (556.0, 476.0) viewDidLayout: (556.0, 476.0) The correct restored size is (556.0, 476.0), but viewDidAppear initially reports the old default size (480.0, 270.0). SwiftUI equivalent struct MyView: View { var body: some View { GeometryReader { geo in VStack {} .onAppear { print(onAppear: (geo.size)) } .onChange(of: geo.size) { print(onChange: (geo.size)) } } } } Logs on launch: onAppear: (900.0, 450.0) onChange: (680.0, 658.0) Problem I need to run some setup code: Only once After the view/window has its correct restored size Withou
Replies
3
Boosts
0
Views
736
Activity
Apr ’26
CLLocationManager permission prompt never appears in Swift Playground
I am building a Swift Playgrounds App project on iPad running iPadOS 26.0.1 using the latest version of Swift Playgrounds. I need to access Core Location for a plant location logging app. What I have done: • Created an App project (not a Playground) in Swift Playgrounds • Enabled ‘Core Location When in Use’ in the app capabilities (accessed by tapping the app name) • Implemented a CLLocationManager with CLLocationManagerDelegate • Called manager.requestWhenInUseAuthorization() from .onAppear in a SwiftUI view • Called manager.startUpdatingLocation() immediately after The problem: The location permission prompt never appears when the app runs. The app does not appear in Settings → Privacy & Security → Location Services at all. There are no error messages or crashes — the app simply never requests location access. What I have ruled out: • The capability IS enabled in Swift Playgrounds app settings • The app runs without errors otherwise • This is an App project, not a classic Playground, so it shou
Replies
3
Boosts
0
Views
930
Activity
Apr ’26
Reply to SwiftUI TextField.accessibilityIdentifier is not propagated to the underlying UITextField instance.
Hello @Divyashruti, Thank you for your question. SwiftUI views do not necessarily map 1-to-1 to UIKit UIView classes, and so you should not rely on framework calls based on that assumption. Couldn't you stick to using SwiftUI modifiers, such as onChange(of:initial:_:), or use custom bindings? Hoping this helps, Richard Yeh  Developer Technical Support
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Apr ’26
Reply to ToolbarItemGroup With Palette Style Cannot Present a View Controller While the Context Menu Is Visible
Thanks for the post, and great UI in my opinion. Hope as many SwiftUI people jump into this thread but I think the issue is because you are using UIKit. I think based on the error message, the error you are seeing is a UIKit presentation issue when a UI isn’t finished so looks like .palette control group style on iOS is backed by UIKit's context menu system (UIContextMenuInteraction). https://developer.apple.com/documentation/uikit/uicontextmenuinteraction When the menu is open, a private view controller (_UIContextMenuActionsOnlyViewController) is actively being presented. I think the issue here is as UIKit strictly enforces that a UIViewController can only present one view controller at a time, but you call to present(...) fails because the underlying navigation controller is still busy presenting the context menu? Is it timing the issue? If possible, you should avoid calling UIKit's present() manually from a SwiftUI button action. Instead, update a @State or @Published property in your vi
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Apr ’26