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 cod
Search results for
swiftui
16,581 results found
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Here are a few SwiftUI APIs that will allow you to accomplish this. All of these are Scene modifiers, which you can apply to your DocumentGroup. They control how the window sizes based on its content. defaultSize(_:) - Use this to specify the default size of the window when it's first shown. windowResizability(_:) - Using the .contentSize resizability, the window's minimum and maximum size will be based on the size of the Scene's view. Check out the documentation for an example. windowIdealSize(_:) + WindowIdealSize - This modifier lets you customize the behavior when zooming. You can choose to make the window zoom to ideal or maximum size of the Scene's view. windowFullScreenBehavior(_:) - Depending on the configuration of the modifiers above, full screen may become disabled automatically, but if not, you can use this modifier to disable it.
Topic:
Programming Languages
SubTopic:
Swift
Tags:
Since you started with a SwiftUI app, you're better off using the available Info.plist keys to define the contents of your launch screen, rather than a Launch Storyboard like shown in your project. These keys are already configured for you when you create a new SwiftUI app. Configure a launch screen in an information property list explains how to set the keys for existing projects, and UILaunchScreen has the keys and values that are available. One of the most important aspects of launching is that you should downplay it, and there's a section in the Human Interface Guides that you should read regarding this. This typically means that the contents of your launch screen reflect the first screen the customer is going to see once launching is completed, rather than a splash screen for branding. Using large photos like your example here rarely falls in line with those recommendations. — Ed Ford, DTS Engineer
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
Instruments is crashing when the swiftui instrument is stopped (the session is finished) and the transfer begins from device to device: Crashed Thread: 11 Dispatch queue: com.apple.swiftuitracingsupport.reading Exception Type: EXC_BAD_INSTRUCTION (SIGILL) Exception Codes: 0x0000000000000001, 0x0000000000000000 Termination Reason: Namespace SIGNAL, Code 4 Illegal instruction: 4 Terminating Process: exc handler [1633] I've tried removing derived data, reinstalling xcode, updating xcode (I originally thought this might be the issue -- I needed to update to 26.2 from the 26 RC -- the update didn't fix crash or change the crash report), and restarting both devices. I'm running Instruments/Xcode 26.2 on a MacBook Pro 15 (2018) running Mac OS 15.7.2 (24G325) with an iPhone 16 Pro Max running 26.2. Hoping someone else might have seen this or could help me troubleshoot. I find the swiftui instrument be helpful and like to use it :) I can post a complete crash report as well.
line 19: I used the documentation sample for AgeRangeService, but get a Compiler Error: Missing argument for parameter 'in' in call That was for SwiftUI. For UIKit, require in parameter. So code reformatted. Removes all errors except unknown isEligibleForAgeFeatures. All other questions remain. func testAgeRange() async -> Bool { if !isEligibleForAgeFeatures { // Which import needed ? return true // Not called from Texas } do { let response = try await AgeRangeService.shared.requestAgeRange(ageGates: 13, 15, 18, in: self) // Can I use the 4 gate instead ? ageGates: 4, 13, 18 // guard let lowerBound = response.lowerBound else { // // Allow access to under 13 features. // return false // } var lowerBound = 4 switch response { case .declinedSharing: print(User declined to share age.) return false case .sharing(let range): lowerBound = range.lowerBound ?? 4 print(User age range: (range.lowerBound ?? 0)-(range.upperBound ?? 99)) @unknown default: print( fatalError()) return false } var ok = false if lo
Topic:
UI Frameworks
SubTopic:
UIKit
Tags:
Yes, the SwiftUI Inspector feature was removed in Xcode 26, but there are still ways to get design help from Xcode. With Swift Previews, you can identify UI elements using selectable mode and then ask Xcode Intelligence to make any changes, so you can learn on the go. See Writing code with intelligence in Xcode. Travis Trotto - DTS Engineer
Topic:
UI Frameworks
SubTopic:
SwiftUI
There are some code samples in WWDC, but pretty limited and for SwiftUI: https://developer.apple.com/videos/play/wwdc2025/299/ That's not enough to expedite the compliance. Please Apple, could you provide a complete demo code, not requiring SwiftUI.
Topic:
App Store Distribution & Marketing
SubTopic:
General
There are some code samples in WWDC, but pretty limited and for SwiftUI: https://developer.apple.com/videos/play/wwdc2025/299/ That's not enough to expedite the compliance. So maybe the safest is to test location (Texas) and close the app in that case.
Topic:
App Store Distribution & Marketing
SubTopic:
General
Tags:
I am also having the same issue, following the Landmarks tutorial, section 2, step 2. The only available option that appears is Embed. Show SwiftUI Inspector doesn't appear as an option, the canvas mode has been changed to selectable.
Topic:
UI Frameworks
SubTopic:
SwiftUI
My app uses SwiftUI Map and draws Markers, MapPolyline and MapPolygons over it. These all work on actual devices. On the iOS 26.0.1 Simulator running on macOS 26.0.1 Polylines and Polygons do now show. Do others see the same thing?
Thanks for the post. It looks like you're encountering a specific crash related to the SwiftUI instrument in Xcode 26.2, which can be quite frustrating, especially when it interrupts a useful workflow. Given that you've already attempted some common troubleshooting steps like removing derived data, reinstalling, updating Xcode, and restarting devices, and that is a crash on the Instruments app let’s go ahead and file a bug: Once you open the bug report, please post the FB number here for my reference. If you have any questions about filing a bug report, take a look at Bug Reporting: How and Why? Albert Pascual
Worldwide Developer Relations.
Topic:
Developer Tools & Services
SubTopic:
Instruments
Tags:
While preparing my app for Declared Age Range capability usage, I've noticed a weird behaviour: the same code works for iOS, but not for macOS. My project uses same target for both platforms, so the capability is enabled for both platforms. The business logic layer is also shared across between platforms. Both UI layers are writter in SwiftUI. The iCloud account used for testing on iOS and macOS devices is the same, so even the consent is shared across both devices. While requestAgeRange(ageGates:) seems to work just fine for iOS app, for macOS app it always throws Not available error (DeclaredAgeRange.AgeRangeService.Error.notAvailable) Am I missing something? Could the API be somehow unavailable for macOS? Should I use AgeRangeService.shared.requestAgeRange(ageGates:in:) for macOS instead of SwiftUI's @Environment-based approach? Also, after giving permission, is there a way to actually revoke it? In Age Range for Apps menu I can only view the list of apps that have my consent to share my
Hello, We are having an issue with the RequestReview API and were hoping to get some help. We know that there is no guarantee that the in-app review modal will show and we know that there are 3 circumstances in which it will definitely not appear: if the user has turned off in-app review/ratings in their settings if the user has submitted a review for that app on that device within the last 365 days if the user has been asked for a review >3 times in the last 365 days When testing our implementation, every single one of our testers did not receive the rating modal despite the fact that we had all our testers turn on the app rating setting and that we have never asked for reviews from our app before. So that seems suspicious. While it is possible that something is up with our code (and I have provided some snippets below) we are also concerned that apple maybe is suppressing it for another reason. We really want to go live with our app review code but unfortunately we are not able to get confidence that it
Topic:
App & System Services
SubTopic:
StoreKit
Generally, non-Latin keyboards like Arabic switch to Latin when ⌘ (Command) is pressed, to allow pressing ⌘P. The letter P is also written on Apple’s keyboards as an indication for this use case. That said you’re correct, not all shortcuts defined in QWERTY are doable on all other keyboard layouts. That’s why AppKit, UIKit, and SwiftUI apps automatically localize keyboard shortcuts. Developers are encouraged to define the shortcuts in QWERTY – English (also called “ABC”), and then at runtime they’ll adapt automatically for the user’s current input method & language directionality. Many parameters are taken into account to compute the best hotkey equivalent, for hundreds of keyboard layouts, and left-to-right vs. right-to-left. For instance, ⌘[ is ⌘] in right-to-left, or ⌘^ in ABC – AZERTY. The system is taking care of localizing menus & shortcut display. There is no API currently for your shortcut customization panel to fetch the localized shortcut display like OS menus do. You can request an
Topic:
Accessibility & Inclusion
SubTopic:
General
Tags:
Hello! What UIKit API enables you to add a view below the navigation bar and extend the scroll edge effect below it in iOS 26? safeAreaBar is how you do it in SwiftUI but I need to achieve this design in my UIKit app (which has a collection view in a view controller in a navigation controller). struct ContentView: View { let segments = [First, Second, Third] @State private var selectedSegment = First var body: some View { NavigationStack { List(0..<50, id: .self) { i in Text(Row (i + 1)) } .safeAreaBar(edge: .top) { Picker(Segment, selection: $selectedSegment) { ForEach(segments, id: .self) { Text($0) } } .pickerStyle(.segmented) .padding(.horizontal) .padding(.bottom, 8) } .navigationTitle(Title) .navigationBarTitleDisplayMode(.inline) } } }