Search results for

“swiftui”

17,235 results found

Post

Replies

Boosts

Views

Activity

Reply to Annoying popup window in Xcode Previews when the initial controller of the main storyboard is a macOS window
Thank you for your post and your screenshot. While the screenshot depicts the app as a SwiftUI View, your post explicitly mentions that the app is built using UIKit Storyboards? When utilizing Xcode Previews with a storyboard-based macOS application that retains the default window controller entry point, it is important to note that the app’s entry point is typically defined by a window controller in the storyboard (often linked to the initial scene). In full-screen mode, macOS may preserve this state across UI refreshes. Could you please isolate the entry point of the app and create a new focused project that displays it? Additionally, I recommend providing your expectations so that we can assist you in fulfilling them. If you intend to use SwiftUI, I would suggest sticking to that framework. Albert Pascual
  Worldwide Developer Relations.
Feb ’26
Reply to SwiftUI Menu label: How to center an icon inside a circle?
Thanks for the post. Great question as there are so many ways to accomplish this and probably better than the code I had for an icon. SwiftUI developers please feel free to jump info this thread and provide a simple solution to this problem. Label(title: {}) { Image(systemName: gearshape.fill) .resizable() .aspectRatio(contentMode: .fit) .frame(width: 44, height: 44) .foregroundColor(.white) .background( Circle() .fill(Color.blue.opacity(0.8)) .overlay { Circle() .stroke(Color.white, lineWidth: 2) } ) } The icon maintains perfect circular shape with consistent padding and size. Added subtle background and outline for better visibility. Albert Pascual
  Worldwide Developer Relations.
Topic: Design SubTopic: General Tags:
Feb ’26
Reply to Can TextField handle undo?
Hello @Cykelero, On iPhone, users shake the phone to undo. This is a system setting. From what I found and tried, I don't think TextField or even SwiftUI can disable that interaction on iPhone. But on Mac you can use the toggles listed above or the ⌘+Z function can be overwritten with AppKit commands Let me get a confirmation that I'm not missing anything, if possible. In the meantime let me know if this helps.  Travis Trotto - DTS Engineer
Topic: UI Frameworks SubTopic: SwiftUI
Feb ’26
SwiftUI List: observable reference types not deallocated immediately after refresh
Hello 👋 I ran into a SwiftUI lifecycle gotcha while debugging a List with .refreshable I share the code used to reproduce the issue @Observable final class CounterModel: Identifiable { let id: String var title: String var value: Int init(id: String, title: String, value: Int = 0) { self.id = id self.title = title self.value = value } deinit { print(deinit, title) } } @Observable final class ObservableCountersStore { var counters: [CounterModel] = [ .init(id: 1, title: A), .init(id: 2, title: B), .init(id: 3, title: C) ] func refresh() async { try? await Task.sleep(nanoseconds: 300_000_000) counters = [.init(id: 4, title: D)] } } struct ObservableCountersListView: View { @State private var store = ObservableCountersStore() var body: some View { List { ForEach(store.counters) { counter in ObservableCounterRow(counter: counter) } } .refreshable { await store.refresh() } } } struct ObservableCounterRow: View { let counter: CounterModel var body: some View { Text(counter.title) } } Observation: After cal
2
0
218
Feb ’26
All notarization submissions stuck "In Progress" — first-time notarization, 9 submissions over 16+ hours
I'm submitting my first macOS app (a native SwiftUI menu bar app, signed with Developer ID Application certificate, Hardened Runtime enabled) for notarization using xcrun notarytool submit with keychain profile authentication. All 9 of my submissions have been stuck at In Progress for up to 16 hours. None have transitioned to Accepted or Invalid. Logs are unavailable for all of them (notarytool log returns Submission log is not yet available). Environment macOS: 26.2 (25C56) Xcode: 26.1.1 (17B100) notarytool: 1.1.0 (39) App: Native SwiftUI, universal binary (x86_64 + arm64), ~2.2 MB DMG Bundle ID: com.gro.ask Team ID: 4KT56S2BX6 What I've verified Code signing is valid: $ codesign --verify --deep --strict GroAsk.app passes with no errors $ codesign -dvvv GroAsk.app Authority=Developer ID Application: Jack Wu (4KT56S2BX6) Authority=Developer ID Certification Authority Authority=Apple Root CA CodeDirectory flags=0x10000(runtime) # Hardened Runtime enabled Runtime Version=26.1.0 Format=app bund
2
0
306
Feb ’26
SwiftUI Menu label: How to center an icon inside a circle?
Hi Everyone. Can you help me with my settings icon design. I'm trying to create a circular settings button using Menu. My code here: struct MenuView: View { var body: some View { Menu { Text(Hello) Text(How are you) } label: { Image(systemName: gearshape.fill) .clipShape(Circle()) } .clipShape(Circle()) .padding(.top, 10) .padding(.leading, 20) } } You can see my try, this one looks wrong. It should be like this: Just Circle with setting image inside. Thank you an advance 😭🙏🛐
1
0
767
Feb ’26
How to do settings icon for menu in SwiftUI?
Hi everyone. Can you help me with my settings icon design. I`m trying to create circular setting button using Menu. My code here: struct MenuView: View { var body: some View { Menu { Text(Hello) Text(How are you) } label: { Image(systemName: gearshape.fill) .clipShape(Circle()) } .clipShape(Circle()) .padding(.top, 10) .padding(.leading, 20) } } You can see my try, this one looks wrong. It should be like this: Just Circle with setting image inside. Thank you an advance 😭🙏🛐
1
0
644
Feb ’26
Reply to How does Xcode26.3 Agent know about the API Documentation for non Apple Intelligence
XcodeRead - Read files from the project XcodeWrite - Write files to the project XcodeUpdate - Edit files with str_replace-style patches XcodeGlob - Find files by pattern XcodeGrep - Search file contents XcodeLS - List directory contents XcodeMakeDir - Create directories XcodeRM - Remove files XcodeMV - Move/rename files BuildProject - Build the Xcode project GetBuildLog - Get build output RunAllTests - Run all tests RunSomeTests - Run specific tests GetTestList - List available tests XcodeListNavigatorIssues - Get Xcode issues/errors XcodeRefreshCodeIssuesInFile - Get live diagnostics ExecuteSnippet - Run code in a REPL-like environment RenderPreview - Render SwiftUI previews as images DocumentationSearch - Search Apple docs and WWDC videos XcodeListWindows - List open Xcode windows The above is a list of MCPTools exposed by Xcode. Im am interested in the DocumentationSearch Tool . Here Xcode is able to search only Apple Docs. Lets say i am using a custom .xcframework or i have added HTML Docs of my
Feb ’26
Does Showing User's Current Location on the Map Require 'NSLocationWhenInUseUsageDescription'?
I have a desktop application that shows some real estate properties chosen by the user. The application shows those GPP locations on the map. The SwiftUI code is something like the following. import SwiftUI import MapKit struct ContentView: View { var body: some View ZStack { mapView } } private var mapView: some View { Map(position: $propertyViewModel.mapPosition) { ForEach(propertyViewModel.properties) { property in Annotation(, coordinate: CLLocationCoordinate2D(latitude: property.lat, longitude: property.lon)) { Button { } label: { VStack { Image(systemName: house.circle.fill) .resizable() .scaledToFit() .frame(width: 48) .foregroundStyle(colorScheme == .light ? .white : .black) ... } } .buttonStyle(.borderless) } } UserAnnotation() } .mapControls { MapUserLocationButton() } .mapControlVisibility(.visible) .onAppear { CLLocationManager().requestWhenInUseAuthorization() } } } The application only wants to use the CLLocationManager class so that it can show those locations on the map relat
1
0
334
Feb ’26
Reply to Can I disable a SwiftUI View from being a draggable source, but still leave it enabled as a dropDestination?
Thank you for your question. I recommend providing a focused sample project, such as the image Image(“playerJersey_red”), which we will all be missing. I will need to replace it with a different image. Regarding the dropDestination cellContent, I understand that you define it, but it would be beneficial to have a sample that can be executed quickly and shared with others for verification. I think it is possible to have a view enabled as a drop destination but disabled as a draggable source based on certain conditions. The issue you're encountering with the .disabled modifier affecting both dragging and dropping could be because it disables all user interactions for the view. Instead, you should conditionally apply the .draggable modifier only when there is a player available? Use content.player.map { $0 } to provide a value only when player is not nil. This makes the view draggable only if a player exists and should keep the .dropDestination modifier without any conditions since you want all cells to be valid
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’26
Can I disable a SwiftUI View from being a draggable source, but still leave it enabled as a dropDestination?
My app has a collection of Cell Views. some of the views' model objects include a Player, and others do not. I want to use drag and drop to move a player from one cell to another. I only want cells that contain a player to be valid drag sources. All cells will be valid drop destinations. When I uncomment the .disabled line both drag and drop become disabled. Is it possible to keep a view enabled as a dropDestination but disabled as a draggable source? VStack { Image(playerJersey_red) if let player = content.player { Text(player.name) } } .draggable(content) // .disabled(content.player == nil) .dropDestination(for: CellContent.self) { items, location in One thing I tried was to wrap everything in a ZStack and put a rectangle with .opacity(0.02) above the Image/Text VStack. I then left draggable modifying my VStack and moved dropDestination to the clear rectangle. This didn't work as I wasn't able to initiate a drag when tapping on the rectangle. Any other ideas or suggestions? thanks
4
0
225
Feb ’26
Transperent title bar changed to gray when refocus
Hello, I'm trying to create game in macos with transperent titlebar. The title bar t stay transperent when I click inside, but changed to gray when the window resize or get out of focus. How can I make it stay transperent all the time? I did all of this: window.styleMask.insert(.fullSizeContentView) window.titlebarAppearsTransparent = true window.titlebarSeparatorStyle = .none window.titleVisibility = .hidden window.isMovableByWindowBackground = true window.isOpaque = false window.backgroundColor = .black in the swiftUI view created zstack that start with: var body: some View { ZStack { Color.black.ignoresSafeArea() help please :) Thanks.
Topic: UI Frameworks SubTopic: General
2
0
240
Feb ’26
How do i use dynamic data for my SwiftUI ScrollView without destroying performance?
Currently i am trying really hard to create experience like the Apple fitness app. So the main view is a single day and the user can swipe between days. The week would be displayed in the toolbar and provide a shortcut to scroll to the right day. I had many attempts at solving this and it can work. You can create such an interface with SwiftUI. However, changing the data on every scroll makes limiting view updates hard and additionally the updates are not related to my code directly. Instruments show me long updates, but they belong to SwiftUI and all the advice i found does not apply or help. struct ContentView: View { @State var journey = JourneyPrototype(selection: 0) @State var position: Int? = 0 var body: some View { ScrollView(.horizontal) { LazyHStack(spacing: 0) { ForEach(journey.collection, id: .self) { index in Listing(index: index) .id(index) } } .scrollTargetLayout() } .scrollTargetBehavior(.paging) .scrollPosition(id: $position) .onChange(of: position) { oldValue, newValue in jo
0
0
79
Feb ’26
Reply to SwiftUI onChange fires twice when filtering data from @Observable store
@DTS Engineer Thanks a lot for the detailed explanation — that makes sense. It seems that when migrating directly from ObservableObject to @Observable, extra care is needed around update ordering and intermediate states. In my case, this behavior leads to unexpected UI results, such as the scroll position ending up in an incorrect state (as shown in the screenshot above). I can consistently reproduce this on a real iPad Pro (M4) running iOS 26.2.1, where the UI visually jumps and then settles at an unintended position. I’ll need to adjust my approach to work around this behavior. I’d also be very interested to hear more from the SwiftUI team on the intended patterns or best practices for avoiding these intermediate states in UI code.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’26
Reply to Annoying popup window in Xcode Previews when the initial controller of the main storyboard is a macOS window
Thank you for your post and your screenshot. While the screenshot depicts the app as a SwiftUI View, your post explicitly mentions that the app is built using UIKit Storyboards? When utilizing Xcode Previews with a storyboard-based macOS application that retains the default window controller entry point, it is important to note that the app’s entry point is typically defined by a window controller in the storyboard (often linked to the initial scene). In full-screen mode, macOS may preserve this state across UI refreshes. Could you please isolate the entry point of the app and create a new focused project that displays it? Additionally, I recommend providing your expectations so that we can assist you in fulfilling them. If you intend to use SwiftUI, I would suggest sticking to that framework. Albert Pascual
  Worldwide Developer Relations.
Replies
Boosts
Views
Activity
Feb ’26
Reply to SwiftUI Menu label: How to center an icon inside a circle?
Thanks for the post. Great question as there are so many ways to accomplish this and probably better than the code I had for an icon. SwiftUI developers please feel free to jump info this thread and provide a simple solution to this problem. Label(title: {}) { Image(systemName: gearshape.fill) .resizable() .aspectRatio(contentMode: .fit) .frame(width: 44, height: 44) .foregroundColor(.white) .background( Circle() .fill(Color.blue.opacity(0.8)) .overlay { Circle() .stroke(Color.white, lineWidth: 2) } ) } The icon maintains perfect circular shape with consistent padding and size. Added subtle background and outline for better visibility. Albert Pascual
  Worldwide Developer Relations.
Topic: Design SubTopic: General Tags:
Replies
Boosts
Views
Activity
Feb ’26
Reply to Can TextField handle undo?
Hello @Cykelero, On iPhone, users shake the phone to undo. This is a system setting. From what I found and tried, I don't think TextField or even SwiftUI can disable that interaction on iPhone. But on Mac you can use the toggles listed above or the ⌘+Z function can be overwritten with AppKit commands Let me get a confirmation that I'm not missing anything, if possible. In the meantime let me know if this helps.  Travis Trotto - DTS Engineer
Topic: UI Frameworks SubTopic: SwiftUI
Replies
Boosts
Views
Activity
Feb ’26
SwiftUI List: observable reference types not deallocated immediately after refresh
Hello 👋 I ran into a SwiftUI lifecycle gotcha while debugging a List with .refreshable I share the code used to reproduce the issue @Observable final class CounterModel: Identifiable { let id: String var title: String var value: Int init(id: String, title: String, value: Int = 0) { self.id = id self.title = title self.value = value } deinit { print(deinit, title) } } @Observable final class ObservableCountersStore { var counters: [CounterModel] = [ .init(id: 1, title: A), .init(id: 2, title: B), .init(id: 3, title: C) ] func refresh() async { try? await Task.sleep(nanoseconds: 300_000_000) counters = [.init(id: 4, title: D)] } } struct ObservableCountersListView: View { @State private var store = ObservableCountersStore() var body: some View { List { ForEach(store.counters) { counter in ObservableCounterRow(counter: counter) } } .refreshable { await store.refresh() } } } struct ObservableCounterRow: View { let counter: CounterModel var body: some View { Text(counter.title) } } Observation: After cal
Replies
2
Boosts
0
Views
218
Activity
Feb ’26
All notarization submissions stuck "In Progress" — first-time notarization, 9 submissions over 16+ hours
I'm submitting my first macOS app (a native SwiftUI menu bar app, signed with Developer ID Application certificate, Hardened Runtime enabled) for notarization using xcrun notarytool submit with keychain profile authentication. All 9 of my submissions have been stuck at In Progress for up to 16 hours. None have transitioned to Accepted or Invalid. Logs are unavailable for all of them (notarytool log returns Submission log is not yet available). Environment macOS: 26.2 (25C56) Xcode: 26.1.1 (17B100) notarytool: 1.1.0 (39) App: Native SwiftUI, universal binary (x86_64 + arm64), ~2.2 MB DMG Bundle ID: com.gro.ask Team ID: 4KT56S2BX6 What I've verified Code signing is valid: $ codesign --verify --deep --strict GroAsk.app passes with no errors $ codesign -dvvv GroAsk.app Authority=Developer ID Application: Jack Wu (4KT56S2BX6) Authority=Developer ID Certification Authority Authority=Apple Root CA CodeDirectory flags=0x10000(runtime) # Hardened Runtime enabled Runtime Version=26.1.0 Format=app bund
Replies
2
Boosts
0
Views
306
Activity
Feb ’26
SwiftUI Menu label: How to center an icon inside a circle?
Hi Everyone. Can you help me with my settings icon design. I'm trying to create a circular settings button using Menu. My code here: struct MenuView: View { var body: some View { Menu { Text(Hello) Text(How are you) } label: { Image(systemName: gearshape.fill) .clipShape(Circle()) } .clipShape(Circle()) .padding(.top, 10) .padding(.leading, 20) } } You can see my try, this one looks wrong. It should be like this: Just Circle with setting image inside. Thank you an advance 😭🙏🛐
Replies
1
Boosts
0
Views
767
Activity
Feb ’26
How to do settings icon for menu in SwiftUI?
Hi everyone. Can you help me with my settings icon design. I`m trying to create circular setting button using Menu. My code here: struct MenuView: View { var body: some View { Menu { Text(Hello) Text(How are you) } label: { Image(systemName: gearshape.fill) .clipShape(Circle()) } .clipShape(Circle()) .padding(.top, 10) .padding(.leading, 20) } } You can see my try, this one looks wrong. It should be like this: Just Circle with setting image inside. Thank you an advance 😭🙏🛐
Replies
1
Boosts
0
Views
644
Activity
Feb ’26
SwiftUI can not find
Hi there, I just re-install 26.2, but I got many issues regarding to SwiftUI's components. How can I fix it? Do I need download or install something else?
Replies
1
Boosts
0
Views
332
Activity
Feb ’26
Reply to How does Xcode26.3 Agent know about the API Documentation for non Apple Intelligence
XcodeRead - Read files from the project XcodeWrite - Write files to the project XcodeUpdate - Edit files with str_replace-style patches XcodeGlob - Find files by pattern XcodeGrep - Search file contents XcodeLS - List directory contents XcodeMakeDir - Create directories XcodeRM - Remove files XcodeMV - Move/rename files BuildProject - Build the Xcode project GetBuildLog - Get build output RunAllTests - Run all tests RunSomeTests - Run specific tests GetTestList - List available tests XcodeListNavigatorIssues - Get Xcode issues/errors XcodeRefreshCodeIssuesInFile - Get live diagnostics ExecuteSnippet - Run code in a REPL-like environment RenderPreview - Render SwiftUI previews as images DocumentationSearch - Search Apple docs and WWDC videos XcodeListWindows - List open Xcode windows The above is a list of MCPTools exposed by Xcode. Im am interested in the DocumentationSearch Tool . Here Xcode is able to search only Apple Docs. Lets say i am using a custom .xcframework or i have added HTML Docs of my
Replies
Boosts
Views
Activity
Feb ’26
Does Showing User's Current Location on the Map Require 'NSLocationWhenInUseUsageDescription'?
I have a desktop application that shows some real estate properties chosen by the user. The application shows those GPP locations on the map. The SwiftUI code is something like the following. import SwiftUI import MapKit struct ContentView: View { var body: some View ZStack { mapView } } private var mapView: some View { Map(position: $propertyViewModel.mapPosition) { ForEach(propertyViewModel.properties) { property in Annotation(, coordinate: CLLocationCoordinate2D(latitude: property.lat, longitude: property.lon)) { Button { } label: { VStack { Image(systemName: house.circle.fill) .resizable() .scaledToFit() .frame(width: 48) .foregroundStyle(colorScheme == .light ? .white : .black) ... } } .buttonStyle(.borderless) } } UserAnnotation() } .mapControls { MapUserLocationButton() } .mapControlVisibility(.visible) .onAppear { CLLocationManager().requestWhenInUseAuthorization() } } } The application only wants to use the CLLocationManager class so that it can show those locations on the map relat
Replies
1
Boosts
0
Views
334
Activity
Feb ’26
Reply to Can I disable a SwiftUI View from being a draggable source, but still leave it enabled as a dropDestination?
Thank you for your question. I recommend providing a focused sample project, such as the image Image(“playerJersey_red”), which we will all be missing. I will need to replace it with a different image. Regarding the dropDestination cellContent, I understand that you define it, but it would be beneficial to have a sample that can be executed quickly and shared with others for verification. I think it is possible to have a view enabled as a drop destination but disabled as a draggable source based on certain conditions. The issue you're encountering with the .disabled modifier affecting both dragging and dropping could be because it disables all user interactions for the view. Instead, you should conditionally apply the .draggable modifier only when there is a player available? Use content.player.map { $0 } to provide a value only when player is not nil. This makes the view draggable only if a player exists and should keep the .dropDestination modifier without any conditions since you want all cells to be valid
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Feb ’26
Can I disable a SwiftUI View from being a draggable source, but still leave it enabled as a dropDestination?
My app has a collection of Cell Views. some of the views' model objects include a Player, and others do not. I want to use drag and drop to move a player from one cell to another. I only want cells that contain a player to be valid drag sources. All cells will be valid drop destinations. When I uncomment the .disabled line both drag and drop become disabled. Is it possible to keep a view enabled as a dropDestination but disabled as a draggable source? VStack { Image(playerJersey_red) if let player = content.player { Text(player.name) } } .draggable(content) // .disabled(content.player == nil) .dropDestination(for: CellContent.self) { items, location in One thing I tried was to wrap everything in a ZStack and put a rectangle with .opacity(0.02) above the Image/Text VStack. I then left draggable modifying my VStack and moved dropDestination to the clear rectangle. This didn't work as I wasn't able to initiate a drag when tapping on the rectangle. Any other ideas or suggestions? thanks
Replies
4
Boosts
0
Views
225
Activity
Feb ’26
Transperent title bar changed to gray when refocus
Hello, I'm trying to create game in macos with transperent titlebar. The title bar t stay transperent when I click inside, but changed to gray when the window resize or get out of focus. How can I make it stay transperent all the time? I did all of this: window.styleMask.insert(.fullSizeContentView) window.titlebarAppearsTransparent = true window.titlebarSeparatorStyle = .none window.titleVisibility = .hidden window.isMovableByWindowBackground = true window.isOpaque = false window.backgroundColor = .black in the swiftUI view created zstack that start with: var body: some View { ZStack { Color.black.ignoresSafeArea() help please :) Thanks.
Topic: UI Frameworks SubTopic: General
Replies
2
Boosts
0
Views
240
Activity
Feb ’26
How do i use dynamic data for my SwiftUI ScrollView without destroying performance?
Currently i am trying really hard to create experience like the Apple fitness app. So the main view is a single day and the user can swipe between days. The week would be displayed in the toolbar and provide a shortcut to scroll to the right day. I had many attempts at solving this and it can work. You can create such an interface with SwiftUI. However, changing the data on every scroll makes limiting view updates hard and additionally the updates are not related to my code directly. Instruments show me long updates, but they belong to SwiftUI and all the advice i found does not apply or help. struct ContentView: View { @State var journey = JourneyPrototype(selection: 0) @State var position: Int? = 0 var body: some View { ScrollView(.horizontal) { LazyHStack(spacing: 0) { ForEach(journey.collection, id: .self) { index in Listing(index: index) .id(index) } } .scrollTargetLayout() } .scrollTargetBehavior(.paging) .scrollPosition(id: $position) .onChange(of: position) { oldValue, newValue in jo
Replies
0
Boosts
0
Views
79
Activity
Feb ’26
Reply to SwiftUI onChange fires twice when filtering data from @Observable store
@DTS Engineer Thanks a lot for the detailed explanation — that makes sense. It seems that when migrating directly from ObservableObject to @Observable, extra care is needed around update ordering and intermediate states. In my case, this behavior leads to unexpected UI results, such as the scroll position ending up in an incorrect state (as shown in the screenshot above). I can consistently reproduce this on a real iPad Pro (M4) running iOS 26.2.1, where the UI visually jumps and then settles at an unintended position. I’ll need to adjust my approach to work around this behavior. I’d also be very interested to hear more from the SwiftUI team on the intended patterns or best practices for avoiding these intermediate states in UI code.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Feb ’26