Provide views, controls, and layout structures for declaring your app's user interface using SwiftUI.

Posts under SwiftUI tag

200 Posts

Post

Replies

Boosts

Views

Activity

Supported way for a watchOS clock app to stay frontmost after the screen dims?
I'm building a standalone watchOS app (SwiftUI, watch-only) whose main screen is its own full-screen clock. Users who choose this clock want it to remain the screen they see on wrist raise, instead of returning to the system watch face after the inactivity timeout. I'd like to know whether watchOS supports this for an App Store app, and which API to use. What I've looked at (watchOS 27.2 SDK, Xcode 27.2): Always On + Return to Clock. The app supports the Always On state. This works up to the Return to Clock interval the user chooses (at most one hour, per "Taking advantage of frontmost app state"). After that, the system face returns. WKApplication.isFrontmostTimeoutExtended. The documentation says it has had no effect since watchOS 7. In a test, reading it back gave false, and the app went to the background after about 2 minutes. WKExtendedRuntimeSession. The documentation asks developers to pick a session type based on the app's actual purpose (self care, mindfulness, physical therapy, smart alarm). None of these fits a clock, so I'm not using one to gain runtime. App Intents supportedModes / LongRunningIntent. These bring the app to the foreground when an intent runs, or run long background work. I couldn't find a way to use them to return automatically after the timeout. openSystemURL with the app's own URL scheme from a background callback. This didn't reopen the app. Other clock apps on the App Store offer a "keep active" style option, so I'm wondering whether a supported mechanism exists that I've missed. Questions: Is there a supported API or capability that lets a user-selected clock app stay frontmost, or come back automatically, after the inactivity timeout? Normal exits must still work: the Digital Crown, other apps, notifications, locking and Sleep Focus. If this isn't supported, is the limit intentional? Is per-app Return to Clock plus Always On the intended maximum? I can share a minimal sample (FrontmostClockProbe) that uses only public APIs and logs scene phase and luminance state. Thanks!
0
0
8
40m
Supported way to hide the system time in a full-screen watchOS clock app?
I'm building a standalone watchOS app (SwiftUI, watch-only) whose main screen is its own full-screen clock. The system time in the top-right corner duplicates our clock, so we'd like to hide it while this view is visible. I'd like to know which API is supported for this in an App Store app. What I tried (watchOS 27.2 SDK, Xcode 27.2): .persistentSystemOverlays(.hidden) on the root view and on the scene. The system time stays visible. In a variant with a NavigationStack and a hidden navigation bar, the time was briefly absent after launch, but it came back within about 20 seconds. .statusBarHidden(_:) and .toolbarVisibility(.hidden, for: .statusBar) are marked unavailable on watchOS in the SDK. View._statusBarHidden(_:) hides the system time reliably. In the watchOS SwiftUI interface it is public, available on watchOS since 6.0, and has no @_spi. It inlines to _statusBar(hidden:). However, it's underscored and I can't find documentation for it. Minimal example: struct ClockView: View { var body: some View { MyFullScreenClock() .persistentSystemOverlays(.hidden) // documented, but time remains visible ._statusBarHidden(true) // hides the time, but undocumented } }I've noticed this modifier in shipping open-source watchOS code, for example Home Assistant's watch app (Sources/WatchApp/Home/WatchHomeView.swift). That doesn't tell me whether Apple supports it, though. Questions: Is _statusBarHidden(_:) / _statusBar(hidden:) a supported API for a distributed watchOS app? If not, is there a documented way for a full-screen clock app to hide the system time, or is the system time intentionally always shown in third-party apps? I can share a small sample project that toggles between the documented overlay preference and the underscored modifier. Thanks!
0
0
8
41m
Keeping the display awake during hands-free auto-scroll in a watchOS reading app
I develop Folito, a free watchOS app for reading EPUB books on Apple Watch. We added an auto-scroll mode: the text scrolls continuously at a speed the user sets with the Digital Crown, so they can read hands-free with their wrist raised. The display dims after the wake timeout because auto-scroll isn't user interaction, so the text becomes hard to read after 15–70 seconds while the user is still reading. What we've considered Pausing on isLuminanceReduced and resuming on tap. This works, but it needs a touch every minute. Continuing in Always On (luminance reduced) with ~1 Hz line-by-line updates. This is our current plan, but the text is dimmed and SE models have no Always On. WKExtendedRuntimeSession. None of the session types (self care, mindfulness, physical therapy, smart alarm, workout) describes reading, and we don't want to misuse one. HKWorkoutSession. Not appropriate, because it would record fake workouts. Questions Is there a supported way for a frontmost app to keep the display at normal brightness while showing continuously changing content the user is reading, without touch input? Would a WKExtendedRuntimeSession started only while auto-scroll runs (and ended as soon as it pauses or stops) be acceptable for this, and if so, which type? In Always On, what's the recommended way to keep text content advancing (for example, updating a ScrollView position via ScrollViewReader about once per second)? I found thread 720495 (iOS, isIdleTimerDisabled) and thread 122753 (Always On, 2019), but neither covers a watchOS app that needs the display awake while content advances on its own. Deployment target: watchOS 10, SwiftUI. Thanks!
1
0
240
8h
Game Center overlay places its back and Play buttons under the rounded corners (and camera) on iPhone Duo's outer display
Environment Device: iPhone Duo, closed (outer display), iOS 27.2 Xcode 27.1 (27A9275), iOS 27.1 SDK, deployment target iOS 18 SwiftUI app lifecycle (WindowGroup, generated scene manifest, generated UILaunchScreen), not letterboxed What happens On the iPhone Duo's outer display, the Game Center screens that GKAccessPoint.trigger(...) opens put their top controls (the round back button at the top left, the "Play" button at the top right) right up in the display's rounded top corners, where the corner partly clips them. The same screens look correct on other iPhones. The outer display's status sits in a column at the right, so a full-screen window there gets a top safe area inset of 0. On other iPhones the top inset (status bar or Dynamic Island) keeps these buttons clear of the corners. The overlay appears to rely on that inset and has no margin of its own for the display's corner radius. Our own app content on the same display handles this: when the top safe area is 0 we add a fixed top margin. The Game Center overlay has no API for us to do the same, at least none that we can find. Steps to reproduce Sign in to Game Center on an iPhone Duo and keep it closed (outer display). In any app, call GKAccessPoint.shared.trigger(leaderboardID: "<id>", playerScope: .global, timeScope: .allTime, handler: {}) Look at the top corners of the Game Center screen, on the leaderboards list and on a single leaderboard. Expected: the back and Play buttons sit clear of the rounded corners, as on other iPhones. Actual: they sit under the corners (screenshot, though it doesn't show the camera cutout) What we tried (none changed the layout at all) Binding the access point to our window before every trigger: let scene = UIApplication.shared.connectedScenes.compactMap { $0 as? UIWindowScene } .first { $0.activationState == .foregroundActive } if let window = scene?.keyWindow { GKAccessPoint.shared.parentWindow = window } GKAccessPoint.shared.trigger(leaderboardID: id, playerScope: .global, timeScope: .allTime, handler: {}) Hosting GKGameCenterViewController (deprecated in iOS 26, used only for this test) as a child of our own full-screen view controller, with a top safe area margin: final class GameCenterHolder: UIViewController, GKGameCenterControllerDelegate { let screen: GKGameCenterViewController // GKGameCenterViewController(leaderboardID:playerScope:timeScope:) // init sets modalPresentationStyle = .fullScreen override func viewDidLoad() { super.viewDidLoad() screen.gameCenterDelegate = self addChild(screen); view.addSubview(screen.view); screen.didMove(toParent: self) } override func viewSafeAreaInsetsDidChange() { super.viewSafeAreaInsetsDidChange() screen.additionalSafeAreaInsets.top = view.safeAreaInsets.top < 1 ? 20 : 0 } nonisolated func gameCenterViewControllerDidFinish(_ vc: GKGameCenterViewController) { MainActor.assumeIsolated { dismiss(animated: true) } } }The screen opened and worked, but its layout was identical. The same holder, giving the child a smaller frame instead (starting 20 pt lower): override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() let top: CGFloat = view.safeAreaInsets.top < 1 ? 20 : 0 screen.view.frame = view.bounds.inset(by: UIEdgeInsets(top: top, left: 0, bottom: 0, right: 0)) }Still identical, so the screen seems to be drawn by the system outside the app's view hierarchy, out of the app's reach. We also checked the usual causes: the app is built with the iOS 27.1 SDK, uses the scene lifecycle and a generated launch screen, doesn't use UIScreen.main for layout, and fills the outer display edge to edge (not letterboxed).
0
0
83
15h
@FocusedValue from .focusedSceneValue from the Scene Commands
Hi, In iPadOS can we use a .focusedSceneValue, defined from a command/Button inside a Scene, from inside the .command modifier attached to the scene? Like this: @main struct test_focusedSceneValueApp: App {     var body: some Scene {         WindowGroup {             ContentView()         }         .commands {             NavigationCommands()         }     } } struct NavigationCommands: Commands {     @FocusedValue(\.filterAction) var filterAction     var body: some Commands {         CommandMenu("Navigate") {             Button("Test focusedSceneValue") {                 filterAction?()             }             .keyboardShortcut("5")         }     } } struct ContentView: View {     @FocusState var isFiltering: Bool     @State private var focusField: String = "teste field teste"     var body: some View {         TextField("teste focus", text: $focusField)             .focused($isFiltering)             .focusedSceneValue(\.filterAction) {                 print("test successful")                 isFiltering = true             }     } This code is almost the same from the sample code from the documentation, however I can only retrieved nil values from the @FocusedValue and not the defined value. Thanks.
5
0
2.2k
2d
Content View Not Working
Newbie here. I just downloaded the latest version Xcode, because I started a class in iOS coding. Unfortunately I write my first "app" (yeah it's "Hello, World"!) and the ContentView just spins and soins then generates an error meassage that goes back to Apple. By the way the iPhone simulater loads but shows nothing. I spoke with two Apple support people to no avail. Can anyone here help? P.S. The error meassages are always Xcode stopped unexpectedly.
0
0
74
3d
Button or onTapGesture grows its hit region by a fixed amount past the view’s bounds.
SwiftUI Button hit area extends ~16pt beyond its visual frame — expected OS behavior? Hi everyone, I’m working on a custom SwiftUI segmented control and noticed some unexpected hit-testing behavior with Button. I have a button structured roughly like this: Button { selectItem(at: index) } label: { ZStack { if selectedIndex == index { selectedBackground } SegmentCellView( tab: tab, isSelected: selectedIndex == index ) } .frame(maxWidth: .infinity) .contentShape(Rectangle()) } .accessibilityLabel(Text(tab.labelText)) The visual frame of the button has a certain height, but when testing on a real device, I can tap approximately 16pt outside the button's visible frame and the button still receives the tap. This seems to happen even though I explicitly use: .contentShape(Rectangle()) to define the tappable shape. My questions are: Is this ~16pt expansion of the interactive area expected SwiftUI/OS behavior? Is this related to Apple's minimum hit-target/accessibility guidelines being automatically applied to controls such as Button? If so, is there an official API/documentation describing this behavior? Is there a recommended way to make the Button's hit-testing area exactly match the bounds defined by .contentShape(Rectangle()), if that is actually possible? I'm particularly interested in understanding whether this is intentional system behavior or something caused by the ButtonStyle / layout hierarchy. Thanks!
2
1
138
3d
SwiftUI custom focusable view cannot acquire focus programmatically on iPad with a hardware keyboard connected
On iPad, a SwiftUI view using .focusable(interactions: .edit) and .focused($isFocused) cannot acquire focus when a hardware keyboard is already connected. Setting isFocused = true from a button leaves it false. Tapping the view also leaves it unfocused, although the tap is received. Pressing Tab can focus the same view. struct FocusProbeView: View { @FocusState private var isFocused: Bool var body: some View { VStack { Text("Target") .focusable(interactions: .edit) .focused($isFocused) .onTapGesture { print("Target tapped") } Text("isFocused = \(isFocused)") Button("Focus target") { isFocused = true } } .defaultFocus($isFocused, true) } }Steps to reproduce: Run this view on an iPad with a hardware keyboard connected. Tap “Focus target”, then tap “Target”. Observe that isFocused remains false. Press Tab. The target can receive focus through keyboard navigation. Disconnect the keyboard. Restart the app and tap “Focus target” again. isFocused becomes true. Reconnecting the keyboard does not remove that focus. Expected: A visible custom view marked .focusable(interactions: .edit) can receive focus through @FocusState, including when a hardware keyboard is connected. Actual: Programmatic focus fails when the keyboard is already connected. A native TextField tested with the same button and @FocusState does receive focus. Environment: iPad model: MU1V2NF/A; iPadOS version: 26.7.2; Xcode version: 27.2; hardware keyboard: Logi Folio Touch. iPad model: Device Hub iPad Pro 11-inch (M5); iPadOS version: 27.2; Xcode version: 27.2; hardware keyboard: Device Hub.
0
0
56
3d
iPhone Duo: Keep app on inner display while hinge is open (like Clock)?
Hi! I'm building a night-light app for iPhone Duo. When the device is partly open in tent mode, the lamp starts on the inner display. As soon as I set the phone down on a table, the system moves my window to the outer display, even though the hinge stays open. Apple's Clock app stays on the inner display in the same pose, so it seems possible at the system level. Steps Open iPhone Duo to ~80° (tent). Launch the app on the inner display. Set the device down on a table. Observed (logged from the app) UIHinge.status stays .partiallyOpen (~80°), not .closed. UIDevice.orientation goes portraitUpsideDown → faceDown → landscapeRight. UIScreen.didDisconnectNotification fires and UIScreen.screens drops the inner screen. The window moves to the outer screen (466×678). What I've tried Restricting UISupportedInterfaceOrientations to portrait only Turning on Rotation Lock Reading UIHingeInteraction (read-only, no effect on display routing) Looking at UISceneAccessory.cameraCapture, which only applies with an active capture session and a fully open device Question Is there a supported way for a scene to prefer or stay on the inner display while the hinge isn't closed? If not, I'll file a Feedback Assistant request. iPhone Duo · iOS 27.2 · Xcode 27.2
1
0
46
4d
Tab grayed out, but not disabled
Bug report: FB25495244 This bug also appeared with Xcode 27; it worked previously. scenario: A TabView with, for example, 4 tabs. Data in ContentView is loaded via @Query. In ContentBindingView, the same thing is done, but using a parameter instead of SwiftData. ContentView: If no data is available, the system automatically switches to tab 4 at the start; while you can click on other tabs, they are disabled, and the system will not switch to them. ContentBindingView: When tabDisabled is set to "true", the system automatically switches to Tab 4 upon startup; while it is possible to click on other tabs, they are disabled, and the system will not switch to them. So far, so good. The first three tabs are only active if at least one data record exists or tabDisabled is "false". Tab 4 is always active and is used for data entry. When data is entered in Tab 4, tab 1 to 3 should become active. However, it appears as though tabs 1 through 3 remain disabled—the icons appear grayed out. That is actually not the case; you can click on the tabs, and as soon as you move away from a tab, its icon is displayed correctly. This issue did not exist in Xcode 26. In Xcode 26, all symbols were displayed correctly from the start, once data had been saved. What I noticed on the iPhone Duo: If you open the program on an iPhone Duo while it is closed, enter some data, then move the app to the background, open the iPhone Duo, and bring the application back to the foreground, tabs 1 through 3 will be active. The entire view is being updated, which is why tabs 1 through 3 are now active—though they should have been active already. A side note: The same issue described in the forum post "A layout bug when using Tab View in SwiftUI (FB25490881)" also occurs in this program. The entire view has shifted upward. The text field is no longer visible—only the Add button remains. In the other views, you can only see half of the text. import SwiftUI struct ContentBindingView: View { @State private var tabDisabled: Bool = true @State private var selection: TabSelection = .tab1 private var isTabDisabled: Bool { print("ContentView.isTabDisabled: \(tabDisabled)") return tabDisabled } var body: some View { TabView(selection: $selection) { Tab("Tab 1", systemImage: "waveform.badge.magnifyingglass", value: .tab1) { Text("tab 1") } .disabled(isTabDisabled) Tab("Tab 2", systemImage: "heart", value: .tab2) { Text("tab 2") } .disabled(tabDisabled) Tab("Tab 3", systemImage: "target", value: .tab3) { Text("tab 3") } .disabled(tabDisabled) Tab("Tab 4", systemImage: "gear", value: .tab4) { AddFriendBindingView(tabDisabled: $tabDisabled) } } .onAppear { print("ContentView onAppear disabled: \(tabDisabled)") if tabDisabled { selection = .tab4 } } .onChange(of: selection) { print("ContentView onChange disabled: \(tabDisabled)") } } }struct AddFriendBindingView: View { @Environment(\.dismiss) private var disdmiss @Binding var tabDisabled: Bool @State private var name: String = "" var body: some View { VStack { TextField("Name", text: $name) Button { addFriend() } label: { Text("Add") } .buttonStyle(.borderedProminent) } .padding() .onAppear { print("AddFriendView onAppear disabled: \(tabDisabled)") } } private func addFriend() { tabDisabled = false name = "" disdmiss() } }Christian
2
0
287
4d
App Store Rejection Risk on iPhone Duo: Custom Tab Bar & Letterboxed Screenshots
Hi, We are preparing our app for the iPhone Duo and have two quick App Store Review questions: Custom Tab Bar: Our app uses a custom (non-system) bottom tab bar that stays horizontal on the Duo. Since it does not automatically adapt to the vertical side rail, will it be rejected under design guidelines? Letterboxed Screenshots: Our app runs in compatibility mode (letterboxed) when unfolded. For the mandatory Duo screenshots (April 2027), will submitting "letterboxed screenshots" trigger a Guideline 2.3.3 rejection? Thank you!
2
0
178
4d
macOS 27.2 makes AUv3 plug-ins completely useless as soon as the user accesses a button with a native submenu.
https://youtu.be/HnNGgYZQBvYJust submitted a bug report FB25497228, and posting it here in hopes to get Apple engineers' attention because it's such a bad bug that macOS 27.2 introduced, and don't think it has a workaround unless Apple fixes it. This wasn't an issue in 27.0. Summary: Opening a native submenu in an out-of-process AUv3 plug-in and dismissing it without selecting anything will make the plug-in UI completely unresponsive to mouse input, and any animation will stop also. Only restart solves it. I can reproduce this with Mela in both Logic Pro and Ableton Live 12. I've attached a demo project to the bug report. It's Xcode Audio Unti extension template with a small modification, just added a button with a submenu. Mela can be found here if needed: https://apps.apple.com/us/app/mela-auv3-synth-fx-midi/id1668299428 Steps to reproduce with the attached project Load Mela as an AU instrument in Logic Pro or Ableton Live Open a factory patch. Open a module’s Actions menu (ellipsis buttons) Hover over Insert or Replace until the submenu appears, then dismiss it without selecting anything. Expected result Mela's UI continues to be interactive, e.g. parameters can be easily adjusted and modulation animations continue to work. Actual result No interaction can be performed, wether adjusting a prameter or dragging a module or pressing a button. Animations also stop. This bug renders my plug-in completely useless on macOS as it makes heavy use of submenus. Please fix it! Here's a link to the video demo of the issue: https://youtu.be/HnNGgYZQBvY
1
0
115
5d
SwiftUI View not Refreshing when View Model Controller Data is Updated
With the implementation below, my SwiftUI view is not refreshing when data is retrieved from an HTTP request and stored in a view model controller class. The SwiftUI view calls a shared class of which is the parent of the view model controller, and the view model controller stores the data being accessed from the SwiftUI view. GlobalDataManager: @MainActor @Observable class GlobalDataManager { static let shared = GlobalDataManager() var medications: MedicationsViewModel private init() { let medicationsVM = MedicationsViewModel() self.medications = medicationsVM medicationsVM.globalDataManager = self } }MedicationsViewModel: @MainActor @Observable final class MedicationsViewModel { weak var globalDataManager: GlobalDataManager? var medicationInformation: [MedicationInformation] var asNeededMedications: [AsNeededMedication] var timesMedicationsTaken: [TimeMedicationsTaken] init(globalDataManager: GlobalDataManager? = nil) { self.medicationInformation = [] self.asNeededMedications = [] self.timesMedicationsTaken = [] self.globalDataManager = globalDataManager } func request<T: Encodable>(data: T, requestType: RequestType) async { do { let response = try await HTTPRequestService.shared.request(requestType: requestType, body: data, dataID: nil) if response.success { let decodedData = try DataDecoderService.shared.decode(MedicationData.self, from: response.data) medicationInformation = decodedData.medicationInformation asNeededMedications = decodedData.asNeededMedications timesMedicationsTaken = decodedData.timesMedicationsTaken } } catch let error { globalDataManager?.updateError(error.localizedDescription) } } }Medications View: struct Medications: View { @State private var globalDataManager = GlobalDataManager.shared @State var sheetOpen: Bool = false var body: some View { MedicationTimesList(medicationTimes: globalDataManager.medications.timesMedicationsTaken) .sheet(isPresented: $sheetOpen) { CreateAndUpdateMedicationInformation(viewModel: globalDataManager.medications, sheetOpen: $sheetOpen) } }} Button within CreateAndUpdateMedicationInformation: struct CreateAndUpdateMedicationInformation: View { var viewModel: MedicationsViewModel var body: some View { WideButton(label: "Add Medication", buttonState: $buttonState) .onChange(of: buttonState) { _, newState in if newState { let medicationInformation = MedicationInformation() Task { await viewModel.request(data: medicationInformation, requestType: .addNewMedication) } sheetOpen = false } } }When pressing a button within the CreateAndUpdateMedicationInformation view, the request() function is called, which updates the variable timesMedicationTaken that is stores the data to be displayed in the Medications view. In the request function variables update, but the SwiftUI view does not. How can this be resolved so the Medications view refreshes when timesMedicationTaken and the other variables in the request() function are updated?
Topic: Design SubTopic: General Tags:
0
0
544
6d
A small scrolling ticker pins GPU at ~50% on a rich screen but ~0% on a blank one — is whole-tree compositing at the animation's rate the expected cost?
I have a SwiftUI clock-radio app on iPhone (ProMotion display). The face is a rich, layered screen (glass panels, gradients, shadows). One element is a 340×46 pt text ticker strip that scrolls continuously. Its GPU behaviour is reproducible and, to me, surprising: Measurements (Xcode GPU gauge used only for within-session relative contrasts; cadence from an in-app frame-pacing log): With the ticker scrolling, GPU sits at a ~50% plateau. The step is binary: one scroller or three scrollers cost the same. Frames are never dropped: 16.7 ms median frame time, ~3% of frames over 20 ms. The GPU bills heavily for frames it renders on time. The same strip scrolling on an otherwise blank screen costs ~0%. The ticker visible but static costs 0%. Motion is the trigger; the cost scales with what surrounds the strip, not with the strip itself. What I have tried: SwiftUI offset animation of the text — baseline behaviour above. A fully severed Canvas leaf: own layer subtree, own CADisplayLink, snapshot-fed, no view-tree publishing or subscriptions — identical cost on the full face (and literally 0% redrawing alone on a blank screen at full frame rate). Pre-rendered bitmap content scrolled instead of text — identical. The strip hosted in a separate UIWindow above the face — identical, measured with the strip visibly scrolling in its seat. Pinning the strip's CADisplayLink.preferredFrameRateRange to exactly 30 Hz (minimum = maximum = preferred = 30) — no change. .compositingGroup() on the panel subtree — a modest reduction only. What works: removing the motion duty (scroll once, then park — cost collapses), and, elsewhere in the app, a pull-model spectrum visualiser replaced a publish-driven one and its cost vanished. Severing worked for the visualiser but not for the ticker. Questions: Is this step the expected consequence of the WWDC22 session 10083 rule (the display refresh rate is set by the highest-frame-rate animation in the app) composed with whole-layer-tree compositing per presented frame? Is there any dirty-region scoping that a layer structure like ours defeats? The 30 Hz pin above was hard (min = max = preferred). Would a CAFrameRateRange in the 15–24 Hz band that Apple's ProMotion guidance suggests for small, slow animations behave materially differently, or is that distinction already settled by the 30 Hz result? Is there a known construction for a continuously scrolling ticker that lets the GPU idle between updates? Happy to share a minimal repro or the pacing logs if useful.
2
0
522
1w
Thin border around VideoPlayer
A thin gray border appears around assets presented using VideoPlayer. It was tested on iPhone 8, iPhone 13 mini, and iPhone 15, and the border only appeared on the 13 mini. The iOS version didn't matter, we checked the 13 mini on both iOS 18 and iOS 26 and the border appeared on both. I created a minimal version of the app with just the VideoPlayer and the asset and the frame still appeared. We tried different assets and it was visible on all of them. import SwiftUI import AVKit struct ContentView: View { private let player = AVPlayer(url: Bundle.main.url(forResource: "sample", withExtension: "mp4")!) var body: some View { VideoPlayer(player: player) .frame(width: 300, height: 200) } }I found someone that had the same exact problem on Reddit and StackOverflow: https://www.reddit.com/r/swift/comments/8s87hm/weird_borders_around_avplayerviewcontroller/ https://stackoverflow.com/questions/50927561/weird-borders-around-avplayerviewcontroller and their solution included setting: playerLayer.shouldRasterize = true playerLayer.rasterizationScale = UIScreen.main.scaleThis fixed the issue but isn't suitable for our app due to offscreen rendering performance. They also found that issue on other devices, noting: "After testing this code on multiple devices (actual physical devices, not simulators), this bug appears to happen only on Plus devices (I tested it on i8 on iOS 11, i8+ on iOS 11, iX on iOS 11 and i6+ on iOS 10)." The bug doesn't appear on simulator, isn't visible on a screenshot, the frame disappears when using accessibility zoom. When we encoded the video file to Apple ProRes the border disappeared, but the size of the video bumped from 342 KB to 6.3 MB so we couldn't do that. I'm attaching photo from this person's post since our issue looked exactly the same. Has anyone had a similar issue and maybe found another workaround?
1
1
293
1w
A layout bug when using Tab View in SwiftUI
I've been getting some unexpected behavior when using TabView as the root view in SwiftUI, which I believe to be a bug. I created a barebones app to isolate the bug and will paste the code at the end for anyone who wants to try to reproduce it if you have a physical Duo device. Details below copied from my Feedback ticket FB25490881. Xcode 27.1. What's the bug? When you have a TabView as the root view inside the ContentView.swift and you open the app on the outer screen, then swipe it to the background, unfold the phone and tap the app to bring it to the foreground, any UI element without a fixed frame size gets moved off screen. And any UI element with a fixed frame size gets moved to the very top of the screen. See my two screenshots of outer vs inner display. How to reproduce: 1- Unzip the project folder and open it in Xcode. 2- With a physical Duo on hand, run the app on the Duo. 3- On the outer screen, launch the app. 4- Swipe the app to the background (Do not swipe completely to close the app, just swipe it to the background so it is still running) 5- Unfold the iPhone Duo completely open. 6- Tap the app icon to bring it to the foreground. 7- Look at the broken UI. Also note even the side tab bar itself is broken, it has no padding with the edge of the screen. This is managed by the system. The workaround to fix it: 1- Go to the ContentView.Swift in Xcode. 2- Uncomment "NavigationStack {" on line 13. 3- Uncomment the closing bracket "}" on line 2. 4- Repeat the previous from how to reproduce the bug. My hypothesis: The system reports 0 height for the inner screen in that moment you bring the app to the foreground. Anything with a fixed frame will move to the top, anything with flexible height will not be visible. This only happens when TabView is the root of the scene. Other Useful Information: I hit a very similar bug to this in my main app that I'm still developing, unfortunately I was not able to reproduce it in a sandbox simple app. The bug was: 1- Open the app on outer screen 2- While the app is open, tilt the Duo to the back at a certain angle 3- Unfold the Duo 4- You get this exact same bug where everything with a flexible height disappears off screen or collapses to zero if it's in between UI elements with fixed heights. And everything moves to the top of the screen. I'm not sure why I wasn't able to reproduce it on a sandbox app, but the fix was the same, either remove the TabView completely or put it inside a NavigationStack. I want to stress that this one had to do with the backwards tilt of the phone itself while unfolding it, very weird I know. ContentView.swift: import SwiftUI @available(iOS 27.1, *) struct ContentView: View { var body: some View { // NavigationStack { TabView { HomeTabView() .tabItem { Label("Home", systemImage: "house") } StoreView() .tabItem { Label("Store", systemImage: "bag") } } .tint(Color.black) // } } } HomeTabView.swift: import SwiftUI @available(iOS 27.1, *) struct HomeTabView: View { var body: some View { VStack { Text("Jenny") .font(.largeTitle) .fontWeight(.bold) .padding() .frame(maxWidth: .infinity) .frame(height: 200) .background(Color.gray, in: .rect(cornerRadius: 28)) Spacer() Circle() .fill(Color.blue) .frame(width: 100, height: 100) .padding(.bottom, 50) } .contentMargins(for: .container, edges: .horizontal) } } StoreView.swift is just an default empty swiftUI file with the default Text("Hello, World!")
2
0
407
1w
TabView(.page) extended under the tab bar shifts its pages up after the container height shrinks while visible
Summary A page-style TabView that extends under the bottom tab bar with .ignoresSafeArea(edges: .bottom) leaves its pages shifted upward after its height shrinks while it is on screen. The shift is half of the bottom safe area (41.67 pt with an 83.33 pt tab bar area), and the top of each page is hidden. The internal UICollectionView (contentInsetAdjustmentBehavior == .automatic) seems to briefly add the bottom safe area to adjustedContentInset.bottom during the resize. The inset goes back to 0 afterwards, but the visible cell is left at frame.minY == -41.67. Environment Xcode 27.0 (27A266a), iPhone Duo Simulator (iOS 27.1), deployment target iOS 18.0 In a unit test it also reproduces when only the window height shrinks (386×678 → 386×600), so it does not depend on the foldable device Steps to reproduce Run the code below on the iPhone Duo Simulator while it is folded Unfold the device Expected The red "Top of page 0" area stays directly below the yellow header, as it does when the app is launched unfolded. Actual The top of the red area is hidden under the header. Log output: folded (launch): height=628.00 adjustedContentInset.bottom=0.00 cell.minY=0.00 after unfolding: height=619.00 adjustedContentInset.bottom=0.00 cell.minY=-41.67In this sample the page returns to its position when the device is folded again. In our app it stays shifted, and after the shift, tapping to switch pages sometimes stops working until the user swipes. Notes Removing .ignoresSafeArea(edges: .bottom) avoids the issue, but the content then no longer extends under the translucent tab bar Setting edgesForExtendedLayout = [] on the hosting controller also avoids it, with the same visual change. safeAreaRegions = [] and setContentScrollView(nil, for:) do not help A non-transparent background on the TabView or its pages, as suggested in https://developer.apple.com/forums/thread/762286, does not help. The trigger here is a size change, not a page switch, so this seems to be a different issue Current workaround: find the internal UICollectionView through the superview chain and set contentInsetAdjustmentBehavior = .never. This works, but it relies on the private view hierarchy. Is there a supported way to avoid this? Minimal reproduction import SwiftUI import UIKit // A TabView(.page) extended under the tab bar with .ignoresSafeArea(edges: .bottom). // Resizing the window while it is visible (e.g. unfolding) shifts the page up. struct PagerView: View { @State private var selection = 0 var body: some View { VStack(spacing: 0) { Color.yellow.frame(height: 50).overlay(Text("Header")) TabView(selection: $selection) { ForEach(0..<2) { index in ScrollView { Color.red.frame(height: 120).overlay(Text("Top of page \(index)")) ForEach(0..<30) { Text("Row \($0)").frame(maxWidth: .infinity, minHeight: 44) } } .tag(index) } } .tabViewStyle(.page(indexDisplayMode: .never)) } .ignoresSafeArea(edges: .bottom) } } final class PagerViewController: UIHostingController<PagerView> { override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { [weak self] in self?.logCollectionView() } } private func logCollectionView() { func find(_ view: UIView) -> UICollectionView? { view as? UICollectionView ?? view.subviews.lazy.compactMap(find).first } guard let collectionView = find(view) else { return } let cellMinY = collectionView.visibleCells.first?.frame.minY ?? .nan NSLog("FORUM height=%.2f adjustedContentInset.bottom=%.2f cell.minY=%.2f", collectionView.bounds.height, collectionView.adjustedContentInset.bottom, cellMinY) } } @main final class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, configurationForConnecting session: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { let configuration = UISceneConfiguration(name: nil, sessionRole: session.role) configuration.delegateClass = SceneDelegate.self return configuration } } final class SceneDelegate: UIResponder, UIWindowSceneDelegate { var window: UIWindow? func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { let pager = PagerViewController(rootView: PagerView()) pager.tabBarItem = UITabBarItem(title: "Pager", image: UIImage(systemName: "square"), tag: 0) let other = UIViewController() other.tabBarItem = UITabBarItem(title: "Other", image: UIImage(systemName: "circle"), tag: 1) let tabBarController = UITabBarController() tabBarController.viewControllers = [pager, other] window = UIWindow(windowScene: scene as! UIWindowScene) window?.rootViewController = tabBarController window?.makeKeyAndVisible() } }
3
2
388
1w
iPhone: Inspector Sheet Issue with Navigation Toolbar Toggle
Hello, I think this might be a bug, but I'm not sure (see the code below). FB25486625 On iPhone, when the inspector is presented as a SHEET, swiping down to dismiss it (instead of tapping the close button inside the inspector) causes the navigation toolbar toggle to stop working properly: tapping it once won't reopen the inspector. You have to tap it twice (turning it on and off again) to make the inspector appear again. This doesn't happen when the inspector is presented as a SIDEBAR on iPad or macOS. import SwiftUI struct ContentView: View { @State private var showInspector = false var body: some View { NavigationStack{ Text("Hello, world!") .padding() .inspector(isPresented: $showInspector) { Button("Close Inspector", role: .cancel) { showInspector.toggle() } Text("On iPhone, with inspector as SHEET, if you swipe to close (instead of tap the close button), the toggle in the navigation toolbar won't open the inspector next time (half the time). It doesn't affect inspector as SIDEBAR on iPad") .padding() Spacer() } .toolbar { Toggle(isOn: $showInspector) { Label("Open", systemImage: "sidebar.trailing") } } } } } #Preview { ContentView() }
0
0
85
1w
Supported way for a watchOS clock app to stay frontmost after the screen dims?
I'm building a standalone watchOS app (SwiftUI, watch-only) whose main screen is its own full-screen clock. Users who choose this clock want it to remain the screen they see on wrist raise, instead of returning to the system watch face after the inactivity timeout. I'd like to know whether watchOS supports this for an App Store app, and which API to use. What I've looked at (watchOS 27.2 SDK, Xcode 27.2): Always On + Return to Clock. The app supports the Always On state. This works up to the Return to Clock interval the user chooses (at most one hour, per "Taking advantage of frontmost app state"). After that, the system face returns. WKApplication.isFrontmostTimeoutExtended. The documentation says it has had no effect since watchOS 7. In a test, reading it back gave false, and the app went to the background after about 2 minutes. WKExtendedRuntimeSession. The documentation asks developers to pick a session type based on the app's actual purpose (self care, mindfulness, physical therapy, smart alarm). None of these fits a clock, so I'm not using one to gain runtime. App Intents supportedModes / LongRunningIntent. These bring the app to the foreground when an intent runs, or run long background work. I couldn't find a way to use them to return automatically after the timeout. openSystemURL with the app's own URL scheme from a background callback. This didn't reopen the app. Other clock apps on the App Store offer a "keep active" style option, so I'm wondering whether a supported mechanism exists that I've missed. Questions: Is there a supported API or capability that lets a user-selected clock app stay frontmost, or come back automatically, after the inactivity timeout? Normal exits must still work: the Digital Crown, other apps, notifications, locking and Sleep Focus. If this isn't supported, is the limit intentional? Is per-app Return to Clock plus Always On the intended maximum? I can share a minimal sample (FrontmostClockProbe) that uses only public APIs and logs scene phase and luminance state. Thanks!
Replies
0
Boosts
0
Views
8
Activity
40m
Supported way to hide the system time in a full-screen watchOS clock app?
I'm building a standalone watchOS app (SwiftUI, watch-only) whose main screen is its own full-screen clock. The system time in the top-right corner duplicates our clock, so we'd like to hide it while this view is visible. I'd like to know which API is supported for this in an App Store app. What I tried (watchOS 27.2 SDK, Xcode 27.2): .persistentSystemOverlays(.hidden) on the root view and on the scene. The system time stays visible. In a variant with a NavigationStack and a hidden navigation bar, the time was briefly absent after launch, but it came back within about 20 seconds. .statusBarHidden(_:) and .toolbarVisibility(.hidden, for: .statusBar) are marked unavailable on watchOS in the SDK. View._statusBarHidden(_:) hides the system time reliably. In the watchOS SwiftUI interface it is public, available on watchOS since 6.0, and has no @_spi. It inlines to _statusBar(hidden:). However, it's underscored and I can't find documentation for it. Minimal example: struct ClockView: View { var body: some View { MyFullScreenClock() .persistentSystemOverlays(.hidden) // documented, but time remains visible ._statusBarHidden(true) // hides the time, but undocumented } }I've noticed this modifier in shipping open-source watchOS code, for example Home Assistant's watch app (Sources/WatchApp/Home/WatchHomeView.swift). That doesn't tell me whether Apple supports it, though. Questions: Is _statusBarHidden(_:) / _statusBar(hidden:) a supported API for a distributed watchOS app? If not, is there a documented way for a full-screen clock app to hide the system time, or is the system time intentionally always shown in third-party apps? I can share a small sample project that toggles between the documented overlay preference and the underscored modifier. Thanks!
Replies
0
Boosts
0
Views
8
Activity
41m
Keeping the display awake during hands-free auto-scroll in a watchOS reading app
I develop Folito, a free watchOS app for reading EPUB books on Apple Watch. We added an auto-scroll mode: the text scrolls continuously at a speed the user sets with the Digital Crown, so they can read hands-free with their wrist raised. The display dims after the wake timeout because auto-scroll isn't user interaction, so the text becomes hard to read after 15–70 seconds while the user is still reading. What we've considered Pausing on isLuminanceReduced and resuming on tap. This works, but it needs a touch every minute. Continuing in Always On (luminance reduced) with ~1 Hz line-by-line updates. This is our current plan, but the text is dimmed and SE models have no Always On. WKExtendedRuntimeSession. None of the session types (self care, mindfulness, physical therapy, smart alarm, workout) describes reading, and we don't want to misuse one. HKWorkoutSession. Not appropriate, because it would record fake workouts. Questions Is there a supported way for a frontmost app to keep the display at normal brightness while showing continuously changing content the user is reading, without touch input? Would a WKExtendedRuntimeSession started only while auto-scroll runs (and ended as soon as it pauses or stops) be acceptable for this, and if so, which type? In Always On, what's the recommended way to keep text content advancing (for example, updating a ScrollView position via ScrollViewReader about once per second)? I found thread 720495 (iOS, isIdleTimerDisabled) and thread 122753 (Always On, 2019), but neither covers a watchOS app that needs the display awake while content advances on its own. Deployment target: watchOS 10, SwiftUI. Thanks!
Replies
1
Boosts
0
Views
240
Activity
8h
Game Center overlay places its back and Play buttons under the rounded corners (and camera) on iPhone Duo's outer display
Environment Device: iPhone Duo, closed (outer display), iOS 27.2 Xcode 27.1 (27A9275), iOS 27.1 SDK, deployment target iOS 18 SwiftUI app lifecycle (WindowGroup, generated scene manifest, generated UILaunchScreen), not letterboxed What happens On the iPhone Duo's outer display, the Game Center screens that GKAccessPoint.trigger(...) opens put their top controls (the round back button at the top left, the "Play" button at the top right) right up in the display's rounded top corners, where the corner partly clips them. The same screens look correct on other iPhones. The outer display's status sits in a column at the right, so a full-screen window there gets a top safe area inset of 0. On other iPhones the top inset (status bar or Dynamic Island) keeps these buttons clear of the corners. The overlay appears to rely on that inset and has no margin of its own for the display's corner radius. Our own app content on the same display handles this: when the top safe area is 0 we add a fixed top margin. The Game Center overlay has no API for us to do the same, at least none that we can find. Steps to reproduce Sign in to Game Center on an iPhone Duo and keep it closed (outer display). In any app, call GKAccessPoint.shared.trigger(leaderboardID: "<id>", playerScope: .global, timeScope: .allTime, handler: {}) Look at the top corners of the Game Center screen, on the leaderboards list and on a single leaderboard. Expected: the back and Play buttons sit clear of the rounded corners, as on other iPhones. Actual: they sit under the corners (screenshot, though it doesn't show the camera cutout) What we tried (none changed the layout at all) Binding the access point to our window before every trigger: let scene = UIApplication.shared.connectedScenes.compactMap { $0 as? UIWindowScene } .first { $0.activationState == .foregroundActive } if let window = scene?.keyWindow { GKAccessPoint.shared.parentWindow = window } GKAccessPoint.shared.trigger(leaderboardID: id, playerScope: .global, timeScope: .allTime, handler: {}) Hosting GKGameCenterViewController (deprecated in iOS 26, used only for this test) as a child of our own full-screen view controller, with a top safe area margin: final class GameCenterHolder: UIViewController, GKGameCenterControllerDelegate { let screen: GKGameCenterViewController // GKGameCenterViewController(leaderboardID:playerScope:timeScope:) // init sets modalPresentationStyle = .fullScreen override func viewDidLoad() { super.viewDidLoad() screen.gameCenterDelegate = self addChild(screen); view.addSubview(screen.view); screen.didMove(toParent: self) } override func viewSafeAreaInsetsDidChange() { super.viewSafeAreaInsetsDidChange() screen.additionalSafeAreaInsets.top = view.safeAreaInsets.top < 1 ? 20 : 0 } nonisolated func gameCenterViewControllerDidFinish(_ vc: GKGameCenterViewController) { MainActor.assumeIsolated { dismiss(animated: true) } } }The screen opened and worked, but its layout was identical. The same holder, giving the child a smaller frame instead (starting 20 pt lower): override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() let top: CGFloat = view.safeAreaInsets.top < 1 ? 20 : 0 screen.view.frame = view.bounds.inset(by: UIEdgeInsets(top: top, left: 0, bottom: 0, right: 0)) }Still identical, so the screen seems to be drawn by the system outside the app's view hierarchy, out of the app's reach. We also checked the usual causes: the app is built with the iOS 27.1 SDK, uses the scene lifecycle and a generated launch screen, doesn't use UIScreen.main for layout, and fills the outer display edge to edge (not letterboxed).
Replies
0
Boosts
0
Views
83
Activity
15h
@FocusedValue from .focusedSceneValue from the Scene Commands
Hi, In iPadOS can we use a .focusedSceneValue, defined from a command/Button inside a Scene, from inside the .command modifier attached to the scene? Like this: @main struct test_focusedSceneValueApp: App {     var body: some Scene {         WindowGroup {             ContentView()         }         .commands {             NavigationCommands()         }     } } struct NavigationCommands: Commands {     @FocusedValue(\.filterAction) var filterAction     var body: some Commands {         CommandMenu("Navigate") {             Button("Test focusedSceneValue") {                 filterAction?()             }             .keyboardShortcut("5")         }     } } struct ContentView: View {     @FocusState var isFiltering: Bool     @State private var focusField: String = "teste field teste"     var body: some View {         TextField("teste focus", text: $focusField)             .focused($isFiltering)             .focusedSceneValue(\.filterAction) {                 print("test successful")                 isFiltering = true             }     } This code is almost the same from the sample code from the documentation, however I can only retrieved nil values from the @FocusedValue and not the defined value. Thanks.
Replies
5
Boosts
0
Views
2.2k
Activity
2d
Content View Not Working
Newbie here. I just downloaded the latest version Xcode, because I started a class in iOS coding. Unfortunately I write my first "app" (yeah it's "Hello, World"!) and the ContentView just spins and soins then generates an error meassage that goes back to Apple. By the way the iPhone simulater loads but shows nothing. I spoke with two Apple support people to no avail. Can anyone here help? P.S. The error meassages are always Xcode stopped unexpectedly.
Replies
0
Boosts
0
Views
74
Activity
3d
Button or onTapGesture grows its hit region by a fixed amount past the view’s bounds.
SwiftUI Button hit area extends ~16pt beyond its visual frame — expected OS behavior? Hi everyone, I’m working on a custom SwiftUI segmented control and noticed some unexpected hit-testing behavior with Button. I have a button structured roughly like this: Button { selectItem(at: index) } label: { ZStack { if selectedIndex == index { selectedBackground } SegmentCellView( tab: tab, isSelected: selectedIndex == index ) } .frame(maxWidth: .infinity) .contentShape(Rectangle()) } .accessibilityLabel(Text(tab.labelText)) The visual frame of the button has a certain height, but when testing on a real device, I can tap approximately 16pt outside the button's visible frame and the button still receives the tap. This seems to happen even though I explicitly use: .contentShape(Rectangle()) to define the tappable shape. My questions are: Is this ~16pt expansion of the interactive area expected SwiftUI/OS behavior? Is this related to Apple's minimum hit-target/accessibility guidelines being automatically applied to controls such as Button? If so, is there an official API/documentation describing this behavior? Is there a recommended way to make the Button's hit-testing area exactly match the bounds defined by .contentShape(Rectangle()), if that is actually possible? I'm particularly interested in understanding whether this is intentional system behavior or something caused by the ButtonStyle / layout hierarchy. Thanks!
Replies
2
Boosts
1
Views
138
Activity
3d
SwiftUI custom focusable view cannot acquire focus programmatically on iPad with a hardware keyboard connected
On iPad, a SwiftUI view using .focusable(interactions: .edit) and .focused($isFocused) cannot acquire focus when a hardware keyboard is already connected. Setting isFocused = true from a button leaves it false. Tapping the view also leaves it unfocused, although the tap is received. Pressing Tab can focus the same view. struct FocusProbeView: View { @FocusState private var isFocused: Bool var body: some View { VStack { Text("Target") .focusable(interactions: .edit) .focused($isFocused) .onTapGesture { print("Target tapped") } Text("isFocused = \(isFocused)") Button("Focus target") { isFocused = true } } .defaultFocus($isFocused, true) } }Steps to reproduce: Run this view on an iPad with a hardware keyboard connected. Tap “Focus target”, then tap “Target”. Observe that isFocused remains false. Press Tab. The target can receive focus through keyboard navigation. Disconnect the keyboard. Restart the app and tap “Focus target” again. isFocused becomes true. Reconnecting the keyboard does not remove that focus. Expected: A visible custom view marked .focusable(interactions: .edit) can receive focus through @FocusState, including when a hardware keyboard is connected. Actual: Programmatic focus fails when the keyboard is already connected. A native TextField tested with the same button and @FocusState does receive focus. Environment: iPad model: MU1V2NF/A; iPadOS version: 26.7.2; Xcode version: 27.2; hardware keyboard: Logi Folio Touch. iPad model: Device Hub iPad Pro 11-inch (M5); iPadOS version: 27.2; Xcode version: 27.2; hardware keyboard: Device Hub.
Replies
0
Boosts
0
Views
56
Activity
3d
iPhone Duo: Keep app on inner display while hinge is open (like Clock)?
Hi! I'm building a night-light app for iPhone Duo. When the device is partly open in tent mode, the lamp starts on the inner display. As soon as I set the phone down on a table, the system moves my window to the outer display, even though the hinge stays open. Apple's Clock app stays on the inner display in the same pose, so it seems possible at the system level. Steps Open iPhone Duo to ~80° (tent). Launch the app on the inner display. Set the device down on a table. Observed (logged from the app) UIHinge.status stays .partiallyOpen (~80°), not .closed. UIDevice.orientation goes portraitUpsideDown → faceDown → landscapeRight. UIScreen.didDisconnectNotification fires and UIScreen.screens drops the inner screen. The window moves to the outer screen (466×678). What I've tried Restricting UISupportedInterfaceOrientations to portrait only Turning on Rotation Lock Reading UIHingeInteraction (read-only, no effect on display routing) Looking at UISceneAccessory.cameraCapture, which only applies with an active capture session and a fully open device Question Is there a supported way for a scene to prefer or stay on the inner display while the hinge isn't closed? If not, I'll file a Feedback Assistant request. iPhone Duo · iOS 27.2 · Xcode 27.2
Replies
1
Boosts
0
Views
46
Activity
4d
Tab grayed out, but not disabled
Bug report: FB25495244 This bug also appeared with Xcode 27; it worked previously. scenario: A TabView with, for example, 4 tabs. Data in ContentView is loaded via @Query. In ContentBindingView, the same thing is done, but using a parameter instead of SwiftData. ContentView: If no data is available, the system automatically switches to tab 4 at the start; while you can click on other tabs, they are disabled, and the system will not switch to them. ContentBindingView: When tabDisabled is set to "true", the system automatically switches to Tab 4 upon startup; while it is possible to click on other tabs, they are disabled, and the system will not switch to them. So far, so good. The first three tabs are only active if at least one data record exists or tabDisabled is "false". Tab 4 is always active and is used for data entry. When data is entered in Tab 4, tab 1 to 3 should become active. However, it appears as though tabs 1 through 3 remain disabled—the icons appear grayed out. That is actually not the case; you can click on the tabs, and as soon as you move away from a tab, its icon is displayed correctly. This issue did not exist in Xcode 26. In Xcode 26, all symbols were displayed correctly from the start, once data had been saved. What I noticed on the iPhone Duo: If you open the program on an iPhone Duo while it is closed, enter some data, then move the app to the background, open the iPhone Duo, and bring the application back to the foreground, tabs 1 through 3 will be active. The entire view is being updated, which is why tabs 1 through 3 are now active—though they should have been active already. A side note: The same issue described in the forum post "A layout bug when using Tab View in SwiftUI (FB25490881)" also occurs in this program. The entire view has shifted upward. The text field is no longer visible—only the Add button remains. In the other views, you can only see half of the text. import SwiftUI struct ContentBindingView: View { @State private var tabDisabled: Bool = true @State private var selection: TabSelection = .tab1 private var isTabDisabled: Bool { print("ContentView.isTabDisabled: \(tabDisabled)") return tabDisabled } var body: some View { TabView(selection: $selection) { Tab("Tab 1", systemImage: "waveform.badge.magnifyingglass", value: .tab1) { Text("tab 1") } .disabled(isTabDisabled) Tab("Tab 2", systemImage: "heart", value: .tab2) { Text("tab 2") } .disabled(tabDisabled) Tab("Tab 3", systemImage: "target", value: .tab3) { Text("tab 3") } .disabled(tabDisabled) Tab("Tab 4", systemImage: "gear", value: .tab4) { AddFriendBindingView(tabDisabled: $tabDisabled) } } .onAppear { print("ContentView onAppear disabled: \(tabDisabled)") if tabDisabled { selection = .tab4 } } .onChange(of: selection) { print("ContentView onChange disabled: \(tabDisabled)") } } }struct AddFriendBindingView: View { @Environment(\.dismiss) private var disdmiss @Binding var tabDisabled: Bool @State private var name: String = "" var body: some View { VStack { TextField("Name", text: $name) Button { addFriend() } label: { Text("Add") } .buttonStyle(.borderedProminent) } .padding() .onAppear { print("AddFriendView onAppear disabled: \(tabDisabled)") } } private func addFriend() { tabDisabled = false name = "" disdmiss() } }Christian
Replies
2
Boosts
0
Views
287
Activity
4d
App Store Rejection Risk on iPhone Duo: Custom Tab Bar & Letterboxed Screenshots
Hi, We are preparing our app for the iPhone Duo and have two quick App Store Review questions: Custom Tab Bar: Our app uses a custom (non-system) bottom tab bar that stays horizontal on the Duo. Since it does not automatically adapt to the vertical side rail, will it be rejected under design guidelines? Letterboxed Screenshots: Our app runs in compatibility mode (letterboxed) when unfolded. For the mandatory Duo screenshots (April 2027), will submitting "letterboxed screenshots" trigger a Guideline 2.3.3 rejection? Thank you!
Replies
2
Boosts
0
Views
178
Activity
4d
macOS 27.2 makes AUv3 plug-ins completely useless as soon as the user accesses a button with a native submenu.
https://youtu.be/HnNGgYZQBvYJust submitted a bug report FB25497228, and posting it here in hopes to get Apple engineers' attention because it's such a bad bug that macOS 27.2 introduced, and don't think it has a workaround unless Apple fixes it. This wasn't an issue in 27.0. Summary: Opening a native submenu in an out-of-process AUv3 plug-in and dismissing it without selecting anything will make the plug-in UI completely unresponsive to mouse input, and any animation will stop also. Only restart solves it. I can reproduce this with Mela in both Logic Pro and Ableton Live 12. I've attached a demo project to the bug report. It's Xcode Audio Unti extension template with a small modification, just added a button with a submenu. Mela can be found here if needed: https://apps.apple.com/us/app/mela-auv3-synth-fx-midi/id1668299428 Steps to reproduce with the attached project Load Mela as an AU instrument in Logic Pro or Ableton Live Open a factory patch. Open a module’s Actions menu (ellipsis buttons) Hover over Insert or Replace until the submenu appears, then dismiss it without selecting anything. Expected result Mela's UI continues to be interactive, e.g. parameters can be easily adjusted and modulation animations continue to work. Actual result No interaction can be performed, wether adjusting a prameter or dragging a module or pressing a button. Animations also stop. This bug renders my plug-in completely useless on macOS as it makes heavy use of submenus. Please fix it! Here's a link to the video demo of the issue: https://youtu.be/HnNGgYZQBvY
Replies
1
Boosts
0
Views
115
Activity
5d
SwiftUI View not Refreshing when View Model Controller Data is Updated
With the implementation below, my SwiftUI view is not refreshing when data is retrieved from an HTTP request and stored in a view model controller class. The SwiftUI view calls a shared class of which is the parent of the view model controller, and the view model controller stores the data being accessed from the SwiftUI view. GlobalDataManager: @MainActor @Observable class GlobalDataManager { static let shared = GlobalDataManager() var medications: MedicationsViewModel private init() { let medicationsVM = MedicationsViewModel() self.medications = medicationsVM medicationsVM.globalDataManager = self } }MedicationsViewModel: @MainActor @Observable final class MedicationsViewModel { weak var globalDataManager: GlobalDataManager? var medicationInformation: [MedicationInformation] var asNeededMedications: [AsNeededMedication] var timesMedicationsTaken: [TimeMedicationsTaken] init(globalDataManager: GlobalDataManager? = nil) { self.medicationInformation = [] self.asNeededMedications = [] self.timesMedicationsTaken = [] self.globalDataManager = globalDataManager } func request<T: Encodable>(data: T, requestType: RequestType) async { do { let response = try await HTTPRequestService.shared.request(requestType: requestType, body: data, dataID: nil) if response.success { let decodedData = try DataDecoderService.shared.decode(MedicationData.self, from: response.data) medicationInformation = decodedData.medicationInformation asNeededMedications = decodedData.asNeededMedications timesMedicationsTaken = decodedData.timesMedicationsTaken } } catch let error { globalDataManager?.updateError(error.localizedDescription) } } }Medications View: struct Medications: View { @State private var globalDataManager = GlobalDataManager.shared @State var sheetOpen: Bool = false var body: some View { MedicationTimesList(medicationTimes: globalDataManager.medications.timesMedicationsTaken) .sheet(isPresented: $sheetOpen) { CreateAndUpdateMedicationInformation(viewModel: globalDataManager.medications, sheetOpen: $sheetOpen) } }} Button within CreateAndUpdateMedicationInformation: struct CreateAndUpdateMedicationInformation: View { var viewModel: MedicationsViewModel var body: some View { WideButton(label: "Add Medication", buttonState: $buttonState) .onChange(of: buttonState) { _, newState in if newState { let medicationInformation = MedicationInformation() Task { await viewModel.request(data: medicationInformation, requestType: .addNewMedication) } sheetOpen = false } } }When pressing a button within the CreateAndUpdateMedicationInformation view, the request() function is called, which updates the variable timesMedicationTaken that is stores the data to be displayed in the Medications view. In the request function variables update, but the SwiftUI view does not. How can this be resolved so the Medications view refreshes when timesMedicationTaken and the other variables in the request() function are updated?
Topic: Design SubTopic: General Tags:
Replies
0
Boosts
0
Views
544
Activity
6d
A small scrolling ticker pins GPU at ~50% on a rich screen but ~0% on a blank one — is whole-tree compositing at the animation's rate the expected cost?
I have a SwiftUI clock-radio app on iPhone (ProMotion display). The face is a rich, layered screen (glass panels, gradients, shadows). One element is a 340×46 pt text ticker strip that scrolls continuously. Its GPU behaviour is reproducible and, to me, surprising: Measurements (Xcode GPU gauge used only for within-session relative contrasts; cadence from an in-app frame-pacing log): With the ticker scrolling, GPU sits at a ~50% plateau. The step is binary: one scroller or three scrollers cost the same. Frames are never dropped: 16.7 ms median frame time, ~3% of frames over 20 ms. The GPU bills heavily for frames it renders on time. The same strip scrolling on an otherwise blank screen costs ~0%. The ticker visible but static costs 0%. Motion is the trigger; the cost scales with what surrounds the strip, not with the strip itself. What I have tried: SwiftUI offset animation of the text — baseline behaviour above. A fully severed Canvas leaf: own layer subtree, own CADisplayLink, snapshot-fed, no view-tree publishing or subscriptions — identical cost on the full face (and literally 0% redrawing alone on a blank screen at full frame rate). Pre-rendered bitmap content scrolled instead of text — identical. The strip hosted in a separate UIWindow above the face — identical, measured with the strip visibly scrolling in its seat. Pinning the strip's CADisplayLink.preferredFrameRateRange to exactly 30 Hz (minimum = maximum = preferred = 30) — no change. .compositingGroup() on the panel subtree — a modest reduction only. What works: removing the motion duty (scroll once, then park — cost collapses), and, elsewhere in the app, a pull-model spectrum visualiser replaced a publish-driven one and its cost vanished. Severing worked for the visualiser but not for the ticker. Questions: Is this step the expected consequence of the WWDC22 session 10083 rule (the display refresh rate is set by the highest-frame-rate animation in the app) composed with whole-layer-tree compositing per presented frame? Is there any dirty-region scoping that a layer structure like ours defeats? The 30 Hz pin above was hard (min = max = preferred). Would a CAFrameRateRange in the 15–24 Hz band that Apple's ProMotion guidance suggests for small, slow animations behave materially differently, or is that distinction already settled by the 30 Hz result? Is there a known construction for a continuously scrolling ticker that lets the GPU idle between updates? Happy to share a minimal repro or the pacing logs if useful.
Replies
2
Boosts
0
Views
522
Activity
1w
Thin border around VideoPlayer
A thin gray border appears around assets presented using VideoPlayer. It was tested on iPhone 8, iPhone 13 mini, and iPhone 15, and the border only appeared on the 13 mini. The iOS version didn't matter, we checked the 13 mini on both iOS 18 and iOS 26 and the border appeared on both. I created a minimal version of the app with just the VideoPlayer and the asset and the frame still appeared. We tried different assets and it was visible on all of them. import SwiftUI import AVKit struct ContentView: View { private let player = AVPlayer(url: Bundle.main.url(forResource: "sample", withExtension: "mp4")!) var body: some View { VideoPlayer(player: player) .frame(width: 300, height: 200) } }I found someone that had the same exact problem on Reddit and StackOverflow: https://www.reddit.com/r/swift/comments/8s87hm/weird_borders_around_avplayerviewcontroller/ https://stackoverflow.com/questions/50927561/weird-borders-around-avplayerviewcontroller and their solution included setting: playerLayer.shouldRasterize = true playerLayer.rasterizationScale = UIScreen.main.scaleThis fixed the issue but isn't suitable for our app due to offscreen rendering performance. They also found that issue on other devices, noting: "After testing this code on multiple devices (actual physical devices, not simulators), this bug appears to happen only on Plus devices (I tested it on i8 on iOS 11, i8+ on iOS 11, iX on iOS 11 and i6+ on iOS 10)." The bug doesn't appear on simulator, isn't visible on a screenshot, the frame disappears when using accessibility zoom. When we encoded the video file to Apple ProRes the border disappeared, but the size of the video bumped from 342 KB to 6.3 MB so we couldn't do that. I'm attaching photo from this person's post since our issue looked exactly the same. Has anyone had a similar issue and maybe found another workaround?
Replies
1
Boosts
1
Views
293
Activity
1w
A layout bug when using Tab View in SwiftUI
I've been getting some unexpected behavior when using TabView as the root view in SwiftUI, which I believe to be a bug. I created a barebones app to isolate the bug and will paste the code at the end for anyone who wants to try to reproduce it if you have a physical Duo device. Details below copied from my Feedback ticket FB25490881. Xcode 27.1. What's the bug? When you have a TabView as the root view inside the ContentView.swift and you open the app on the outer screen, then swipe it to the background, unfold the phone and tap the app to bring it to the foreground, any UI element without a fixed frame size gets moved off screen. And any UI element with a fixed frame size gets moved to the very top of the screen. See my two screenshots of outer vs inner display. How to reproduce: 1- Unzip the project folder and open it in Xcode. 2- With a physical Duo on hand, run the app on the Duo. 3- On the outer screen, launch the app. 4- Swipe the app to the background (Do not swipe completely to close the app, just swipe it to the background so it is still running) 5- Unfold the iPhone Duo completely open. 6- Tap the app icon to bring it to the foreground. 7- Look at the broken UI. Also note even the side tab bar itself is broken, it has no padding with the edge of the screen. This is managed by the system. The workaround to fix it: 1- Go to the ContentView.Swift in Xcode. 2- Uncomment "NavigationStack {" on line 13. 3- Uncomment the closing bracket "}" on line 2. 4- Repeat the previous from how to reproduce the bug. My hypothesis: The system reports 0 height for the inner screen in that moment you bring the app to the foreground. Anything with a fixed frame will move to the top, anything with flexible height will not be visible. This only happens when TabView is the root of the scene. Other Useful Information: I hit a very similar bug to this in my main app that I'm still developing, unfortunately I was not able to reproduce it in a sandbox simple app. The bug was: 1- Open the app on outer screen 2- While the app is open, tilt the Duo to the back at a certain angle 3- Unfold the Duo 4- You get this exact same bug where everything with a flexible height disappears off screen or collapses to zero if it's in between UI elements with fixed heights. And everything moves to the top of the screen. I'm not sure why I wasn't able to reproduce it on a sandbox app, but the fix was the same, either remove the TabView completely or put it inside a NavigationStack. I want to stress that this one had to do with the backwards tilt of the phone itself while unfolding it, very weird I know. ContentView.swift: import SwiftUI @available(iOS 27.1, *) struct ContentView: View { var body: some View { // NavigationStack { TabView { HomeTabView() .tabItem { Label("Home", systemImage: "house") } StoreView() .tabItem { Label("Store", systemImage: "bag") } } .tint(Color.black) // } } } HomeTabView.swift: import SwiftUI @available(iOS 27.1, *) struct HomeTabView: View { var body: some View { VStack { Text("Jenny") .font(.largeTitle) .fontWeight(.bold) .padding() .frame(maxWidth: .infinity) .frame(height: 200) .background(Color.gray, in: .rect(cornerRadius: 28)) Spacer() Circle() .fill(Color.blue) .frame(width: 100, height: 100) .padding(.bottom, 50) } .contentMargins(for: .container, edges: .horizontal) } } StoreView.swift is just an default empty swiftUI file with the default Text("Hello, World!")
Replies
2
Boosts
0
Views
407
Activity
1w
TabView(.page) extended under the tab bar shifts its pages up after the container height shrinks while visible
Summary A page-style TabView that extends under the bottom tab bar with .ignoresSafeArea(edges: .bottom) leaves its pages shifted upward after its height shrinks while it is on screen. The shift is half of the bottom safe area (41.67 pt with an 83.33 pt tab bar area), and the top of each page is hidden. The internal UICollectionView (contentInsetAdjustmentBehavior == .automatic) seems to briefly add the bottom safe area to adjustedContentInset.bottom during the resize. The inset goes back to 0 afterwards, but the visible cell is left at frame.minY == -41.67. Environment Xcode 27.0 (27A266a), iPhone Duo Simulator (iOS 27.1), deployment target iOS 18.0 In a unit test it also reproduces when only the window height shrinks (386×678 → 386×600), so it does not depend on the foldable device Steps to reproduce Run the code below on the iPhone Duo Simulator while it is folded Unfold the device Expected The red "Top of page 0" area stays directly below the yellow header, as it does when the app is launched unfolded. Actual The top of the red area is hidden under the header. Log output: folded (launch): height=628.00 adjustedContentInset.bottom=0.00 cell.minY=0.00 after unfolding: height=619.00 adjustedContentInset.bottom=0.00 cell.minY=-41.67In this sample the page returns to its position when the device is folded again. In our app it stays shifted, and after the shift, tapping to switch pages sometimes stops working until the user swipes. Notes Removing .ignoresSafeArea(edges: .bottom) avoids the issue, but the content then no longer extends under the translucent tab bar Setting edgesForExtendedLayout = [] on the hosting controller also avoids it, with the same visual change. safeAreaRegions = [] and setContentScrollView(nil, for:) do not help A non-transparent background on the TabView or its pages, as suggested in https://developer.apple.com/forums/thread/762286, does not help. The trigger here is a size change, not a page switch, so this seems to be a different issue Current workaround: find the internal UICollectionView through the superview chain and set contentInsetAdjustmentBehavior = .never. This works, but it relies on the private view hierarchy. Is there a supported way to avoid this? Minimal reproduction import SwiftUI import UIKit // A TabView(.page) extended under the tab bar with .ignoresSafeArea(edges: .bottom). // Resizing the window while it is visible (e.g. unfolding) shifts the page up. struct PagerView: View { @State private var selection = 0 var body: some View { VStack(spacing: 0) { Color.yellow.frame(height: 50).overlay(Text("Header")) TabView(selection: $selection) { ForEach(0..<2) { index in ScrollView { Color.red.frame(height: 120).overlay(Text("Top of page \(index)")) ForEach(0..<30) { Text("Row \($0)").frame(maxWidth: .infinity, minHeight: 44) } } .tag(index) } } .tabViewStyle(.page(indexDisplayMode: .never)) } .ignoresSafeArea(edges: .bottom) } } final class PagerViewController: UIHostingController<PagerView> { override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { [weak self] in self?.logCollectionView() } } private func logCollectionView() { func find(_ view: UIView) -> UICollectionView? { view as? UICollectionView ?? view.subviews.lazy.compactMap(find).first } guard let collectionView = find(view) else { return } let cellMinY = collectionView.visibleCells.first?.frame.minY ?? .nan NSLog("FORUM height=%.2f adjustedContentInset.bottom=%.2f cell.minY=%.2f", collectionView.bounds.height, collectionView.adjustedContentInset.bottom, cellMinY) } } @main final class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, configurationForConnecting session: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { let configuration = UISceneConfiguration(name: nil, sessionRole: session.role) configuration.delegateClass = SceneDelegate.self return configuration } } final class SceneDelegate: UIResponder, UIWindowSceneDelegate { var window: UIWindow? func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { let pager = PagerViewController(rootView: PagerView()) pager.tabBarItem = UITabBarItem(title: "Pager", image: UIImage(systemName: "square"), tag: 0) let other = UIViewController() other.tabBarItem = UITabBarItem(title: "Other", image: UIImage(systemName: "circle"), tag: 1) let tabBarController = UITabBarController() tabBarController.viewControllers = [pager, other] window = UIWindow(windowScene: scene as! UIWindowScene) window?.rootViewController = tabBarController window?.makeKeyAndVisible() } }
Replies
3
Boosts
2
Views
388
Activity
1w
iPhone: Inspector Sheet Issue with Navigation Toolbar Toggle
Hello, I think this might be a bug, but I'm not sure (see the code below). FB25486625 On iPhone, when the inspector is presented as a SHEET, swiping down to dismiss it (instead of tapping the close button inside the inspector) causes the navigation toolbar toggle to stop working properly: tapping it once won't reopen the inspector. You have to tap it twice (turning it on and off again) to make the inspector appear again. This doesn't happen when the inspector is presented as a SIDEBAR on iPad or macOS. import SwiftUI struct ContentView: View { @State private var showInspector = false var body: some View { NavigationStack{ Text("Hello, world!") .padding() .inspector(isPresented: $showInspector) { Button("Close Inspector", role: .cancel) { showInspector.toggle() } Text("On iPhone, with inspector as SHEET, if you swipe to close (instead of tap the close button), the toggle in the navigation toolbar won't open the inspector next time (half the time). It doesn't affect inspector as SIDEBAR on iPad") .padding() Spacer() } .toolbar { Toggle(isOn: $showInspector) { Label("Open", systemImage: "sidebar.trailing") } } } } } #Preview { ContentView() }
Replies
0
Boosts
0
Views
85
Activity
1w