Search results for

swiftui

16,580 results found

Post

Replies

Boosts

Views

Activity

help() view modifier
I have a bunch of Buttons with a .help(Text(Help text)) modifier, inside of a VStack which has its own .help() modifier describing the entire section. The VStack help shows up only when I hover over the buttons, and the Button help never shows at all. If I comment out the VStack help, the individual button helps show. How do I get both to show up properly? I want the VStack to show if I am in the roundedBorder, unless I am over a Button with its own .help modifier. import SwiftUI struct BugReport: View { @State private var testp1 = false @State private var testp2 = false var body: some View { VStack { Text(Hello, World!) Button(Test1) { testp1.toggle() } .help(Change the test1) Button(Test2) { testp2.toggle() } .help(Change the test2) } .help(Testing stuff) .roundedBorder(color: .black) } } #Preview { BugReport() }
Topic: UI Frameworks SubTopic: SwiftUI
3
0
310
1w
Reply to Guidance on implementing Declared Age Range API in response to Texas SB2420
It will hurt some Texas users, but not the rest of the world, which is very important. I agree – one of my main concerns is how these laws will impact on all my other users. Should we terminate the app ? You could do that, but it's not a very good user experience. I plan to present some simple messaging that directs users to an Apple support article. Here's a quick sketch of how I'm currently planning to handle this across a few different apps (in SwiftUI). I would appreciate any feedback on this approach, from either a technical or legal standpoint. In my main App struct, I will branch into a new ContentViewWithAgeGate view for iOS 26.2+. WindowGroup { if #available(iOS 26.2, *) { ContentViewWithAgeGate() } else { ContentView() } } ContentViewWithAgeGate acts as a wrapper around ContentView and perfoms the checks: import SwiftUI @preconcurrency import DeclaredAgeRange @available(iOS 26.2, *) struct ContentViewWithAgeGate: View { @Environment(.requestAgeRange) var requestAgeRange @State priv
1w
Reply to Cannot make my app appear in “Share with App” action in Shortcuts – How to allow receiving images from Shortcuts?
When using App Intent, I noticed that we cannot process the image directly within the invoked UI. It appears that this is restricted by Apple’s privacy protections—any attempt to handle the data immediately results in the background privacy indicator showing a blocked status. Therefore, App Intent does not seem to meet our need to process user-provided images directly. This sounds like you implemented a UI snippet as part of your intent, and not all SwiftUI features are available in a UI snippet — for example, these snippets aren't interactive. Details here matter, so to discuss how you can build an intent that works for your needs, it'd be helpful to have a test project or test code that demonstrates what you tried and where you ran into trouble so that we can more fully explore this. — Ed Ford,  DTS Engineer
1w
Reply to Instruments: Trace file had no SwiftUI data
Thank you for your post. Very interesting to me because my recent instrument adventures. Although I am not an expert in Instruments, I recently discovered that you can create a blank template and add individual instruments like SwiftUI by tapping the plus icon. Is that what you are using for your SwiftUI data, and you are not receiving it that way? What template are you using that indicates there is no SwiftUI data on the trace? Could you please provide me with a detailed step-by-step guide to reproduce the issue, including the template and individual instruments you are adding to the instruments? Additionally, please provide any relevant background information about the application you are profiling. Thanks, Albert Pascual
  Worldwide Developer Relations.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
1w
Reply to Guidance on implementing Declared Age Range API in response to Texas SB2420
(0) check if iOS is 26+. Otherwise, proceed without any test (because we cannot do them) Yep, agree. In fact, we specifically need to check for iOS 26.2. in (1), which import to use AppStore.ageRatingCode ? You just need to import storekit to access that. However, as noted below, I'm considering a different option. in (2), if UIKit and not SwiftUI, need the in parameter Indeed you do. Annoyingly, you also need the in parameter if you're putting your code in some class (e.g. some kind of age manager class), and it's not clear to me what you need to pass in (assuming you have a SwiftUI app). where should parental control be tested ? In step (5) ? I honestly don't know at this point – I haven't gotten to that point yet, but as noted below, I'm looking for ways to avoid that side of things. where to deal with change in user's age or repudiation (as required by law if I read properly) My assumption is that if you check the age on every launch, then this should take care of itself. But I could be
1w
Reply to Guidance on implementing Declared Age Range API in response to Texas SB2420
@jwcarr thanks for this detailed analysis. That's the type of advice we would have expected from Apple… I think they have ways to avoid the legal issues. A few more points: There should likely be a step (0) (0) check if iOS is 26+. Otherwise, proceed without any test (because we cannot do them) (1) get the App Store age rating with let appStoreAgeRating = await AppStore.ageRatingCode ?? 18, (2) request the user's age with let ageRangeResponse = try await AgeRangeService.shared.requestAgeRange(ageGates: appStoreAgeRating), (3) check that the user has agreed to share their age, (4) check that lowerBound >= appStoreAgeRating, and (5) check that the verification method is not one of the self-declared methods. If this procedure fails, I should block access to the app and provide a link to Apple's support page A few more questions: in (1), which import to use AppStore.ageRatingCode ? in (2), if UIKit and not SwiftUI, need the in parameter let ageRangeResponse = try await AgeRangeService.shared.requestAg
1w
Reply to (Xcode 26.0 → 26.2) Constant UI flickering in split view mode
Thanks so much for the post and the video itself. Would you be able to provide a focused sample project so I can run it myself and see if you are using UIKit or SwiftUI and what is causing the issue? If so, please share a link to your test project. That'll help us better understand what's going on. If you're not familiar with preparing a test project, take a look at Creating a test project. Thanks Albert Pascual
  Worldwide Developer Relations.
1w
Recurring FigXPCUtilities / FigCaptureSourceRemote err=-17281 logs when using AVCaptureVideoDataOutput on iOS 26.x
Hi everyone, I’m seeing recurring internal AVFoundation camera logs on iOS 26.2 and I’m trying to understand whether this is expected behavior or a regression in the capture pipeline. These logs appear shortly after starting an AVCaptureSession, while video frames are being delivered, and also when the camera is stopped or the capture session is torn down. <<<< FigXPCUtilities >>>> signalled err=-17281 at <>:302 <<<< FigCaptureSourceRemote >>>> Fig assert: err == 0 at bail (FigCaptureSourceRemote.m:569) - (err=-17281) Even in this clean, minimal setup, the same logs appear on iOS 26.2 The exact same logic did not produce these logs on iOS 18.x. To rule out issues caused by my own code, GPT created a minimal SwiftUI example from scratch. My primary interest is to perform real-time processing on the video frames delivered by the camera (via AVCaptureVideoDataOutput), for tasks such as analysis, computer vision, or custom frame handling, while simul
0
0
274
1w
Reply to How to disable native Full Screen and implement custom "Zoom to Fill" with minimum window constraints in MacOs SwiftUI / Appkit
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:
2w
How to disable native Full Screen and implement custom "Zoom to Fill" with minimum window constraints in MacOs SwiftUI / Appkit
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
1
0
522
2w
Reply to XCode26 - Unable to launch Image in storyboard for landscape picture in Portrait orientation
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:
2w
On macOS Settings window navigation bar item is in the center
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
0
0
58
2w
SwiftUI's colorScheme vs preferredColorScheme
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))) } }
1
0
232
2w
Pre-inference AI Safety Governor for FoundationModels (Swift, On-Device)
Hi everyone, I've been building an on-device AI safety layer called Newton Engine, designed to validate prompts before they reach FoundationModels (or any LLM). Wanted to share v1.3 and get feedback from the community. The Problem Current AI safety is post-training — baked into the model, probabilistic, not auditable. When Apple Intelligence ships with FoundationModels, developers will need a way to catch unsafe prompts before inference, with deterministic results they can log and explain. What Newton Does Newton validates every prompt pre-inference and returns: Phase (0/1/7/8/9) Shape classification Confidence score Full audit trace If validation fails, generation is blocked. If it passes (Phase 9), the prompt proceeds to the model. v1.3 Detection Categories (14 total) Jailbreak / prompt injection Corrosive self-negation (I hate myself) Hedged corrosive (Not saying I'm worthless, but...) Emotional dependency (You're the only one who understands) Third-person manipulation (If you refuse, you're proving nobody
0
0
303
2w