I am creating a macOs SwiftUI document based app, and I am struggling with the Window sizes and placements. Right now by default, a normal window has the minimize and full screen options which makes the whole window into full screen mode.
However, I don't want to do this for my app. I want to only allow to fill the available width and height, i.e. exclude the status bar and doc when the user press the fill window mode, and also restrict to resize the window beyond a certain point ( which ideally to me is 1200 x 700 because I am developing on macbook air 13.3-inch in which it looks ideal, but resizing it below that makes the entire content inside messed up ).
I want something like this below instead of the default full screen green
When the user presses the button, it should position centered with perfect aspect ratio from my content ( or the one I want like 1200 x 700 ) and can be able to click again to fill the available width and height excluding the status bar and docs.
Here is my entire @main code :-
@main
struct PhiaApp: App {
@NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
var body: some Scene {
DocumentGroup(newDocument: PhiaProjectDocument()) { file in
ContentView(
document: file.$document,
rootURL: file.fileURL
)
.configureEditorWindow(disableCapture: true)
.background(AppColors.background)
.preferredColorScheme(.dark)
}
.windowStyle(.hiddenTitleBar)
.windowToolbarStyle(.unified)
.defaultLaunchBehavior(.suppressed)
Settings {
SettingsView()
}
}
}
struct WindowAccessor: NSViewRepresentable {
var callback: (NSWindow?) -> Void
func makeNSView(context: Context) -> NSView {
let view = NSView()
DispatchQueue.main.async { [weak view] in
callback(view?.window)
}
return view
}
func updateNSView(_ nsView: NSView, context: Context) { }
}
extension View {
func configureEditorWindow(disableCapture: Bool = true) -> some View {
self.background(
WindowAccessor { window in
guard let window else { return }
if let screen = window.screen ?? NSScreen.main {
let visible = screen.visibleFrame
window.setFrame(visible, display: true)
window.minSize = visible.size
}
window.isMovable = true
window.isMovableByWindowBackground = false
window.sharingType = disableCapture ? .captureBlocked : .captureAllowed
}
)
}
}
This is a basic setup I did for now, this automatically fills the available width and height on launch, but user can resize and can go beyond my desired min width and height which makes the entire content inside messy.
As I said, I want a native way of doing this, respect the content aspect ratio, don't allow to enter full screen mode, only be able to fill the available width and height excluding the status bar and doc, also don't allow to resize below my desired width and height.
Explore the various UI frameworks available for building app interfaces. Discuss the use cases for different frameworks, share best practices, and get help with specific framework-related questions.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Created
Hi,
Overview
I have a Mac app with a settings window. When I add a button it is added to the center.
I want it on the trailing edge, I even tried adding it as confirmationAction but doesn’t work.
Screenshot
Feedback
FB21374186
Steps to reproduce
Run the project on mac
Open the app's settings by pressing ⌘ ,
Notice that the Save button is in the center instead of the trailing edge
Code
App
import SwiftUI
@main
struct SettingsToolbarButtonBugApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
Settings {
SettingsView()
.frame(width: 300, height: 400)
}
}
}
SettingsView
import SwiftUI
struct SettingsView: View {
var body: some View {
NavigationStack {
Form {
Text("Settings window")
}
.toolbar {
ToolbarItem(placement: .confirmationAction) {
// Save button is the center instead of trailing edge
Button("Save") {}
}
}
.navigationTitle("Settings")
}
}
}
Topic:
UI Frameworks
SubTopic:
SwiftUI
SwiftUI's colorScheme modifier is said to be deprecated in favour of preferredColorScheme but the two work differently. See the below sample app, colorScheme changes the underlying view colour while preferredColorScheme doesn't. Is that a bug of preferredColorScheme?
import SwiftUI
struct ContentView: View {
let color = Color(light: .red, dark: .green)
var body: some View {
VStack {
HStack {
color.colorScheme(.light)
color.colorScheme(.dark)
}
HStack {
color.preferredColorScheme(.light)
color.preferredColorScheme(.dark)
}
}
}
}
#Preview {
ContentView()
}
@main struct TheApp: App {
var body: some Scene {
WindowGroup { ContentView() }
}
}
extension UIColor {
convenience init(light: UIColor, dark: UIColor) {
self.init { v in
switch v.userInterfaceStyle {
case .light: light
case .dark: dark
case .unspecified: fatalError()
@unknown default: fatalError()
}
}
}
}
extension Color {
init(light: Color, dark: Color) {
self.init(UIColor(light: UIColor(light), dark: UIColor(dark)))
}
}
using Version 26.2 (17C52) I often get
"Trace file had no SwiftUI data"
why so?
I'm struggling to implement required code for SB2420 compliance.
I try to learn on a very simple use case.
the app is UIKit
Build in Xcode 26.2
it displays a single Hello view with a button that will simply show a "Good day" label.
I assume the app will be rated 4+.
I tried the following code, using available information in Xcode (limited):
import UIKit
import DeclaredAgeRange
// other import needed ?
class ViewController: UIViewController {
@IBOutlet weak var welcomeLabel: UILabel! // initially hidden
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
func testAgeRange() -> Bool {
if !isEligibleForAgeFeatures { // Not found. Which import needed ?
return true // Not called from Texas
}
// Following code from Xcode doc…
do {
let response = try await AgeRangeService.shared.requestAgeRange(ageGates: 13, 15, 18) // Compiler Error: Missing argument for parameter 'in' in call
// Can I add the 4 gate ?
guard let lowerBound = response.lowerBound else {
// Allow access to under 13 features.
return false
}
var ok = false
if lowerBound >= 18 { // Not needed ?
// Allow access to 18+ features.
ok = true
} else if lowerBound >= 15 { // Not needed ?
// Allow access to 15+ features.
ok = true
} else if lowerBound >= 13 { // Not needed ?
// Require parental consent ?
// Allow access to 13+ features.
ok = true // if consent OK
} else {
// Require parental consent ?
// Show age-appropriate content
ok = true // if consent OK
}
return ok // Authorized for all 4+
} catch AgeRangeService.Error.notAvailable {
// No age range provided.
return false
}
}
func executeStart() {
welcomeLabel.isHidden = false
}
@IBAction func start(_ sender: UIButton) {
if #available(iOS 26.0, *) {
if testAgeRange() {
// Need to test for parental control here ?
} else {
// Alert and exit the app ?
}
} else {
// do nothing ? Can we run the app ?
}
executeStart()
}
}
The logic would be:
before allowing action with the start button, check
is it IOS 26+ so that we can call API
if so, is verification needed (Texas SB2420)
if not, we can proceed
if required, test age range
As app is 4+, all ranges should be OK
But need to test parental control
Now, many pending questions in code:
line 14: get an error: Cannot find 'isEligibleForAgeFeatures' in scope
line 19: I used the documentation sample for AgeRangeService, but get a Compiler Error: Missing argument for parameter 'in' in call
line 35: how to implement parental control ?
In addition, in the metadata of the app, should I declare that parental control ?
Age verification?
Mechanism for confirming that a person's age meets the age requirement for accessing content or services
As there is no restriction on age, is it required ?
Any help welcomed as well as link to a comprehensive tutorial.
How to change the image launch screen using story to show picture display in rotated view when ipad in portrait orientation ?
Current launch screen
-Image Portrait Orientation
-Image Landscape Orientation
-Info Setting
Expected launch screen as below (Not Working)
-Expected Launch Screen
I have uploaded the entire sample source here
The latest iPhone model is unable to retrieve the Wi-Fi information it has connected to. The phone's operating system is iOS 26.1, and location permission has also been granted.
"Access Wi-Fi Information" is also configured in the same way
The following is the code I used to obtain Wi-Fi information:
func getCurrentWiFiInfo() -> String? {
guard let interfaces = CNCopySupportedInterfaces() as? [String] else {
return nil
}
for interface in interfaces {
guard let info = CNCopyCurrentNetworkInfo(interface as CFString) as? [String: Any] else {
continue
}
if let ssid = info[kCNNetworkInfoKeySSID as String] as? String,
!ssid.isEmpty {
return ssid
}
}
return nil
}
Hello!
Can you tell me why UIImageWriteToSavedPhotosAlbum stopped working on Mac Catalyst?
This method used to save photos to the library. Now I get an error when trying to save with the same code that previously worked.
error NSError domain: "ALAssetsLibraryErrorDomain" - code: -1 0x0000000cb00b4810
Hi
I have a NSTextView set as the document of a NSScrollView
scrollView.documentView = textView
I want to programatically scroll to a specific offset in the scrollView. I use the following function and it jumps to the right location:
scrollView.documentOffset = offset
However I would like to animate the scrolling. Any suggestions?
Also to mention, I have not flipped the coordinates of the NSTextView
Thanks
Reza
Topic:
UI Frameworks
SubTopic:
AppKit
I'm adapting for iOS 26, and I found that when pressing and slowly swiping the screen, the section header near the bottom of the navigation bar in the tableview flickers frequently. How can I fix this issue?
Please view the video in the github project: issue.mp4
Topic:
UI Frameworks
SubTopic:
UIKit
I need the user to input an emoji but not other characters. I'd like to be able to use an emoji keyboard similar to the one in the Reminders app. How can I do this?
The issue can be reproduced using the simplest code. In Xcode 26 + iOS 26, when a UIBarButtonItem is created using a UIImage, it consistently prints numerous constraint conflict warnings to the console. Below is my test code and the console warnings:
let btn = UIBarButtonItem(systemItem: .trash)
self.toolbarItems = [btn]
Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(
"<NSLayoutConstraint:0x1083b4550 _TtC5UIKitP33_DDE14AA6B49FCAFC5A54255A118E1D8713ButtonWrapper:0x108374e00.width == _UIButtonBarButton:0x1083e8000.width (active)>",
"<NSLayoutConstraint:0x1083b4aa0 'IB_Leading_Leading' H:|-(2)-[_UIModernBarButton:0x103ac62e0] (active, names: '|':_UIButtonBarButton:0x1083e8000 )>",
"<NSLayoutConstraint:0x1083b4af0 'IB_Trailing_Trailing' H:[_UIModernBarButton:0x103ac62e0]-(2)-| (active, names: '|':_UIButtonBarButton:0x1083e8000 )>",
"<NSLayoutConstraint:0x1083b4fa0 'UIView-Encapsulated-Layout-Width' _TtC5UIKitP33_DDE14AA6B49FCAFC5A54255A118E1D8713ButtonWrapper:0x108374e00.width == 0 (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x1083b4af0 'IB_Trailing_Trailing' H:[_UIModernBarButton:0x103ac62e0]-(2)-| (active, names: '|':_UIButtonBarButton:0x1083e8000 )>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
Do you guys know how to fix the render of the text in the accessory view ? If I force the color of text to be .black it work but it will break dark mode, but forcing it .black : .white on color scheme changes makes white to still adapt to what is behind it I have noticed that Apple Music doesn’t have that artifact and it seems to break when images are behind the accessory view
// MARK: - Next Routine Accessory
@available(iOS 26.0, *)
struct NetxRoutinesAccessory: View {
@ObservedObject private var viewModel = RoutineProgressViewModel.shared
@EnvironmentObject var colorSchemeManager: ColorSchemeManager
@EnvironmentObject var routineStore: RoutineStore
@EnvironmentObject var freemiumKit: FreemiumKit
@ObservedObject var petsStore = PetsStore.shared
@Environment(\.colorScheme) private var colorScheme
// Tab accessory placement environment
@Environment(\.tabViewBottomAccessoryPlacement) private var accessoryPlacement
// Navigation callback
var onTap: (() -> Void)?
@State private var isButtonPressed = false
/// Explicit black for light mode, white for dark mode
private var textColor: Color {
colorScheme == .dark ? .trueWhite : .trueBlack
}
/// Returns true when the accessory is in inline/minimized mode
private var isInline: Bool {
accessoryPlacement == .inline
}
var body: some View {
accessoryContent()
.onTapGesture {
onTap?()
}
}
private func accessoryContent() -> some View {
HStack(spacing: 12) {
// Content with smooth transitions
VStack(alignment: .leading, spacing: 2) {
if viewModel.totalTasks == 0 {
Text(NSLocalizedString("Set up routines", comment: "Routines empty state"))
.font(.subheadline.weight(.medium))
.foregroundColor(textColor)
} else if let next = viewModel.nextRoutineTask() {
HStack(spacing: 4) {
Text(NSLocalizedString("Next", comment: "Next routine prefix"))
.font(.caption)
.foregroundColor(textColor)
Text("•")
.font(.caption)
.foregroundColor(textColor)
Text(next.routine.name)
.font(.subheadline.weight(.medium))
.foregroundColor(textColor)
.lineLimit(1)
}
.id("routine-\(next.routine.id)-\(next.time)")
.transition(.opacity.combined(with: .move(edge: .leading)))
HStack(spacing: 4) {
Text(viewModel.petNames(for: next.routine.petIDs))
.font(.caption)
.foregroundColor(textColor)
Text("•")
.font(.caption)
.foregroundColor(textColor)
Text(Routine.displayTimeFormatter.string(from: next.time))
.font(.caption.weight(.medium))
.foregroundColor(colorSchemeManager.accentColor ?? .blue)
}
.id("time-\(next.routine.id)-\(next.time)")
.transition(.opacity.combined(with: .move(edge: .leading)))
} else {
// All tasks completed
Text(NSLocalizedString("All done for today!", comment: "All routines completed"))
.font(.subheadline.weight(.medium))
.foregroundColor(textColor)
.transition(.opacity.combined(with: .scale))
Text("\(viewModel.completedTasks)/\(viewModel.totalTasks) " + NSLocalizedString("tasks", comment: "Tasks count suffix"))
.font(.caption)
.foregroundColor(textColor)
}
}
.animation(colorSchemeManager.reduceMotion ? nil : .snappy(duration: 0.3), value: viewModel.completedTasks)
.animation(colorSchemeManager.reduceMotion ? nil : .snappy(duration: 0.3), value: viewModel.progress)
}
.padding()
.contentShape(.rect)
.animation(colorSchemeManager.reduceMotion ? nil : .snappy(duration: 0.35), value: viewModel.completedTasks)
}
}
Topic:
UI Frameworks
SubTopic:
SwiftUI
We're using XCode 26.1.1
We do not have resource to adopt Liquid Glass design. Hence, we are using the following workaround
<key>UIDesignRequiresCompatibility</key>
<true/>
This is our Storyboard.
Pre XCode 26
Before XCode 26.1.1, the bottom toolbar looks great.
In XCode 26
However, in XCode 26.1.1, the bottom toolbar buttons seems to "Squish together".
Do anyone have any idea, how I can make UIToolbar works by enabling UIDesignRequiresCompatibility?
Thanks.
Issue: The search functionality in FamilyActivityPicker has disappeared on iPadOS 26.0+. This feature was working in previous versions but is now missing.
Framework: FamilyControls
Expected: Search bar should be available in FamilyActivityPicker to help users find apps quickly.
Actual: Search functionality is completely missing.
Impact: Makes app selection difficult for users with many installed apps.
Is this a known issue? If it's a bug, please address it in an upcoming update. If intentional, guidance on alternatives would be appreciated.
Thank you.
I have a borderless NSWindow with transparent background floating at Dock level and with collectionBehavior set to NSWindowCollectionBehaviorCanJoinAllSpaces.
To render its background I was using an NSVisualEffectView, but, with the introduction of Liquid Glass, I decided to replace it with a NSGlassEffectView on Tahoe.
On macOS 26.0 and 26.1 all works fine: my window's background is correctly rendered and updated.
On macOS 26.2 this is not so: the background seems cached and doesn't update if I move my window or if I drag some other window underneath it.
My window's movable property is set to NO (and I need this to be so): dragging is implemented by handling mouseDown, mouseDragged, and mouseUp events.
Just to experiment, I tried setting movable and movableByWindowBackground both to YES. In this case, the NSGlassEffectView is correctly updated if I move the window itself, but doesn't change if I move other windows underneath it.
Has anybody experienced a similar problem on maOS 26.2? If so, is there a way to solve it?
Thanks, Marco
Topic:
UI Frameworks
SubTopic:
AppKit
Since iOS 26.0, the Control Center layout consistently resets in landscape orientation after certain system events.
This issue is still present in the official public release of iOS 26.2.
The reset occurs without a visible reboot and appears to be triggered by a background SpringBoard termination (jetsam) during charging idle maintenance windows (typically overnight while the device is plugged in).
After SpringBoard relaunches:
• The portrait Control Center layout is restored correctly
• The landscape Control Center layout is reinitialized using the default order
This indicates a state restoration failure rather than a user configuration or sync issue.
⸻
Steps to Reproduce:
Use an iPhone 15 Pro running iOS 26.0, 26.1, or 26.2
Manually reorder Control Center controls
Leave the device plugged in and idle overnight
During charging idle, SpringBoard is terminated in the background due to memory pressure (no visible reboot)
Open Control Center the next day:
• Portrait layout is preserved
• Landscape layout has reverted to default
⸻
Expected Result:
Both portrait and landscape Control Center layouts should persist across SpringBoard restarts caused by jetsam or memory pressure, including during charging idle maintenance.
⸻
Actual Result:
After SpringBoard relaunch:
• Portrait layout is restored correctly
• Landscape layout is lost and recreated using the default configuration
⸻
Analytics / Logs (relevant excerpt):
Process: SpringBoard
Case Type: MemoryResourceException
Subtype: MREExceptionFatalLimitActive
This occurs during charging idle and does not require a user-initiated reboot.
⸻
Additional Observations:
• Issue does not occur when the device is idle overnight without charging
• Manual reordering works correctly until the next SpringBoard jetsam
• Resetting settings, disabling iCloud sync, or reinstalling iOS does not resolve the issue
• This behavior has persisted across multiple major and minor releases, indicating a regression or unresolved bug
⸻
Suspected Root Cause:
Incomplete state restoration in ControlCenterKit after SpringBoard relaunch following jetsam during charging idle.
Portrait state is restored; landscape state falls back to default.
Topic:
UI Frameworks
SubTopic:
UIKit
Overview
Tapping on ShareLink crashes the app when ShareLink is added in the toolbar with the placement of secondaryAction
Feedback
FB21337385
Note: Apple engineers please priorities this is a blocker and affects production apps and prevents us from going live.
Environment
Xcode: 26.2 (17C52)
iOS: 26.2
iPadOS: 26.2
Reproduce
Able to reproduce 100% both on Simulator and Device
Isolation of the crash
The crash happens only when the ShareLink is used with the placement .secondaryAction
The crash doesn't 'happen when the ShareLink is used with the placement .primaryAction
Code
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationStack {
Text("Hello, world!")
.toolbar {
ToolbarItem(placement: .primaryAction) {
Button("Dummy") {
print("dummy")
}
}
// Tapping on share button will cause it to crash
// Crash only happens when the ShareLink is used with placement .secondaryAction
// It doesn't crash when placement is primaryAction
ToolbarItem(placement: .secondaryAction) {
ShareLink(item: "Some string")
}
}
}
}
}
Crash stack trace
*** Terminating app due to uncaught exception 'NSGenericException', reason: 'UIPopoverPresentationController (<_UIActivityViewControllerPresentationController: 0x105a3b580>) should have a non-nil sourceView or barButtonItem set before the presentation occurs.'
*** First throw call stack:
(
0 CoreFoundation 0x00000001804f71d0 __exceptionPreprocess + 172
1 libobjc.A.dylib 0x000000018009c094 objc_exception_throw + 72
2 UIKitCore 0x0000000185a5b17c -[UIPopoverPresentationController presentationTransitionWillBegin] + 2712
3 UIKitCore 0x0000000185a65de0 -[UIPresentationController _presentationTransitionWillBegin] + 28
4 UIKitCore 0x0000000185a6523c __80-[UIPresentationController _initViewHierarchyForPresentationSuperview:inWindow:]_block_invoke + 1928
5 UIKitCore 0x0000000185a633ec __77-[UIPresentationController runTransitionForCurrentStateAnimated:handoffData:]_block_invoke_3 + 296
6 UIKitCore 0x00000001868b2950 -[_UIAfterCACommitBlock run] + 64
7 UIKitCore 0x00000001868b2d64 -[_UIAfterCACommitQueue flush] + 164
8 UIKitCore 0x0000000186354f04 _runAfterCACommitDeferredBlocks + 256
9 UIKitCore 0x0000000186346bec _cleanUpAfterCAFlushAndRunDeferredBlocks + 76
10 UIKitCore 0x0000000186346cb4 _UIApplicationFlushCATransaction + 68
11 UIKitCore 0x0000000186263c48 __setupUpdateSequence_block_invoke_2 + 372
12 UIKitCore 0x000000018582f378 _UIUpdateSequenceRunNext + 120
13 UIKitCore 0x00000001862640a4 schedulerStepScheduledMainSectionContinue + 56
14 UpdateCycle 0x00000002501912b4 _ZN2UC10DriverCore18continueProcessingEv + 80
15 CoreFoundation 0x000000018041a4ac __CFMachPortPerform + 164
16 CoreFoundation 0x0000000180456aa8 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 56
17 CoreFoundation 0x00000001804560c0 __CFRunLoopDoSource1 + 480
18 CoreFoundation 0x0000000180455188 __CFRunLoopRun + 2100
19 CoreFoundation 0x000000018044fcec _CFRunLoopRunSpecificWithOptions + 496
20 GraphicsServices 0x0000000192a669bc GSEventRunModal + 116
21 UIKitCore 0x0000000186348574 -[UIApplication _run] + 772
22 UIKitCore 0x000000018634c79c UIApplicationMain + 124
23 SwiftUI 0x00000001da58d620 $s7SwiftUI17KitRendererCommon33_ACC2C5639A7D76F611E170E831FCA491LLys5NeverOyXlXpFAESpySpys4Int8VGSgGXEfU_ + 164
24 SwiftUI 0x00000001da58d368 $s7SwiftUI6runAppys5NeverOxAA0D0RzlF + 180
25 SwiftUI 0x00000001da31b42c $s7SwiftUI3AppPAAE4mainyyFZ + 148
26 ShareLinkSecondaryPlacementDemo.deb 0x0000000104d82b0c $s31ShareLinkSecondaryPlacementDemo0abcdE3AppV5$mainyyFZ + 40
27 ShareLinkSecondaryPlacementDemo.deb 0x0000000104d82bb8 __debug_main_executable_dylib_entry_point + 12
28 dyld 0x0000000104cc53d0 start_sim + 20
29 ??? 0x0000000104ff0d54 0x0 + 4378791252
)
libc++abi: terminating due to uncaught exception of type NSException
I've got a situation where I want the iPad to push an editing view onto the sidebar (like on iPhone) and also display a detail view (no content view). This is working great.
However, I need to determine which item from a List in a NavigationSplitView has been selected and pass this to the detail view (the selection is out of scope).
This works with the List selection parameter, but the item selected is ONLY selected and the child view in the NavigationLink does not get pushed, nor does the detail view get changed.
I either need to figure out a way to capture the selection without the List Selection parameter (Tap Gesture?) or get the navigation to happen even when using the Selection parameter.
I'd appreciate some ideas as I'm a newb just learning SwiftUI.
Topic:
UI Frameworks
SubTopic:
SwiftUI
With iOS 26 there has been a change in behavior with Pickers in the toolbar. The Picker looks expanded unlike other views such as a Button and Menu. See screenshots below. Is this the intended behavior or a bug? (I already submitted a feedback for this at FB19276474)
What Picker looks like in the toolbar:
What Button looks like in the toolbar: