Search results for

“swiftui”

17,490 results found

Post

Replies

Boosts

Views

Activity

Reply to Bug: Xcode 26.2 wants `ENABLE_DEBUG_DYLIB`: How do I enable that in `Package.swift`?
Unfortunately, SwiftPM does not inherit Xcode's build settings at all from a containing project. And there is no way to specify any Xcode build setting in a package manifest. Specifying an executable target with SwiftUI in a package is an interesting case. If I were in your shoes, I'd just pull everything out into another module target in the package and have the executable depend on it. Previewing in that module will work just fine. All the executable needs is the @main entry point. It doesn't need the views or previews to be in that target.
Jul ’26
Reply to Bug: Xcode 26.2 wants `ENABLE_DEBUG_DYLIB`: How do I enable that in `Package.swift`?
I have an executable SwiftUI target in my swift package, and have run into this error also - Previews requires ENABLE_DEBUG_DYLIB=YES to be defined. currently my package.swift has this: .executableTarget( name: ColorPickerDemo, dependencies: [ColorPicker], path: Sources/ColorPickerDemo, swiftSettings: [ .enableUpcomingFeature(ApproachableConcurrency), .define(ENABLE_DEBUG_DYLIB) ], linkerSettings: [ .unsafeFlags([ -Xlinker, -sectcreate, -Xlinker, __TEXT, -Xlinker, __info_plist, -Xlinker, Sources/ColorPickerDemo/Info.plist, ]), ] together with an info.plist for the executable, and the demo swiftui app can be launched. Clearly that isn't enough for previews though.. Any ideas?
Jul ’26
Reply to WidgetKit complications won't update
Data point from July 2026: this appears to work now - at least on current OS versions. Setup: iPhone companion (iOS 26.5) + SwiftUI-lifecycle watchOS app (watchOS 26.5) with WidgetKit accessory complications (no ClockKit) transferCurrentComplicationUserInfo() with a small dictionary payload (~6 keys), complication active on the watch face (isComplicationEnabled == true; the transfer budget was actually consumed: remainingComplicationUserInfoTransfers went 50 → 49 → 48 → 47) Both sides instrumented with file logging; every payload carries a monotonically increasing version, and we redundantly send the same update via updateApplicationContext as a fallback - so I can attribute exactly which channel applied each change Results - 3 consecutive sends while the watch was NOT reachable (isReachable == false on the phone at send time) and the watch app was backgrounded: sent 23:10:42.5 → didReceiveUserInfo on the watch at 23:10:57.6 (15.1 s). Ambiguous: the user happened to foreground the watch app ~150 ms b
Jul ’26
NavigationStack has no animations or back gesture in macOS
When running a native macOS app using SwiftUI and a NavigationStack, clicking any links causes the contents of the stack to change immediately with no animation, and you can't use the usual two-finger swipe gesture to go back. The behavior is correct when running it as a Mac Catalyst app, you get the animated transitions when navigating, and swiping works. Minimal Example: (put this directly inside the WindowGroup) NavigationStack { VStack { NavigationLink { Rectangle().foregroundStyle(.red) } label: { Text(Button) } } }
1
0
373
Jul ’26
Reply to iPadOS extended display architecture
This is very interesting post hope I understand correctly what you trying to accomplish, and more about when talking about MultipleScenes and moving Scenes to external displays. To build a native iPadOS application that utilizes an external display with custom layouts while preserving pointer interaction, you must adopt a Multi-Scene Architecture. But hope other developers also provide their solution here. https://developer.apple.com/documentation/swiftui/scene Treats the external display as an extended desktop. Fully preserves native pointer interaction, hover effects, and custom interactive layouts. You cannot force the window to open full-screen on the external display automatically; the OS or the user dictates window placement, though you can programmatically request a new scene. Because your app will effectively run two independent UI hierarchies (one on the iPad, one on the external display), your architecture must strictly separate UI from state. https://developer.apple.com/documentation/uikit
Topic: Design SubTopic: General Tags:
Jul ’26
Reply to SwiftUI Slider onEditingChanged is unreliable on iOS 26
Has anyone found a workaround or solution? I'm seeing this behavior in Xcode 26.6 (17F113) and MacOS 26.5.2., even with Apple's own example code. import SwiftUI struct SliderViewTest: View { @State private var speed = 50.0 @State private var isEditing = false var body: some View { VStack { Slider( value: $speed, in: 0...100, step: 5 ) { Text(Speed) } minimumValueLabel: { Text(0) } maximumValueLabel: { Text(100) } onEditingChanged: { editing in isEditing = editing } Text((speed)) .foregroundColor(isEditing ? .red : .blue) } } } #Preview { SliderViewTest() .padding() }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’26
Reply to Learn Swift and SwiftUI in my old age?
[quote='836918021, pabugeater2, /thread/836918, /profile/pabugeater2'] find it pleasing/beneficial/productive to learn Swift/SwiftUI? [/quote] Let’s break that down: Pleasing That’s very much gonna depend on you. Beneficial Yes. Regardless of any other factors, there’s solid evidence that learning new stuff is beneficial, especially as you get older. Productive That kinda depends on what you intend to produce (-: As someone who’s not exactly young myself, I’ve started to understand that the time I have left is limited, and that I need to focus on what I enjoy. I absolutely love playing around with computers, so if and when I retire there’s no doubt I’ll continue doing that. Keep in mind that there’s a middle ground, namely using Swift to call the frameworks you already know. If you get pleasure from shipping stuff, that might be a good first step, rather than wrestling with Swift and SwiftUI at the same time. Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myE
Jul ’26
How can a SwiftUI drag provide the actual file URL of an existing file on macOS (as NSOutlineView does)?
I'm dragging existing files from a SwiftUI List (a search result list in a sandboxed, document-based Mac app), and I want drop targets to receive the actual file URL — the same behavior as AppKit's NSOutlineView with outlineView(_:pasteboardWriterForItem:) returning an NSURL: the Finder copies the file, browsers load it, and text views insert its path. My current implementation is Transferable-based: FileRepresentation(exportedContentType: .data) { item in SentTransferredFile(item.fileURL, allowAccessingOriginalFile: true) } .suggestedFileName(.fileURL.lastPathComponent) With this, what receivers get is a temporary copy in the app's own container (Caches/com.apple.SwiftUI.Drag-/), not the actual file URL — despite allowAccessingOriginalFile: true. Dropping on the Finder or onto an application icon works through the copy, but receivers that interpret the URL itself — a browser window, or a text view that inserts the dropped file's path — see the temporary container path. Note that the dragged files li
3
0
429
Jul ’26
Reply to Code Signing (I think)
Can you try running on the simulator instead of on a real device? If you are starting new: Learn swift (https://docs.swift.org/swift-book/documentation/the-swift-programming-language/) Learning iOS development (https://cs193p.stanford.edu) - Use this as a guidance, then once you are comfortable with the basics then refer to Apple documentation / WWDC videos Learn SwiftUI (WWDC videos are pretty good)
Topic: Code Signing SubTopic: General
Jul ’26
Reply to Learn Swift and SwiftUI in my old age?
Last year, at age 73, I decided to switch my hobby programming to Swift/SwiftUI from XOJO. I waited for SwiftUI to mature as UIKit made my eyes glaze over. After about 6 months of grinding, I successfully converted one of my XOJO apps. I now know there's a few things I did sub-optimally, so I'm continuing to learn. Jump in, the water's fine.
Jul ’26
Code Signing (I think)
Just started learning SWIFT. How come this code (in a separate file): // // indexLoader.swift // PhotoViewer // // Created by Bruce Quimby on 7/3/26. // import SwiftUI import SwiftData struct LoadIndex { let indexURL = https://Some URL; func getIndex() { print(The next step will be to get the index from this URL: + indexURL); } } makes my build fail with: Cannot create a iOS App Development provisioning profile for Just-Me.PhotoViewer.Retrieve-Index. Personal development teams, including ME, do not support the Accessory Setup Extension capability.
Topic: Code Signing SubTopic: General
2
0
480
Jul ’26
Learn Swift and SwiftUI in my old age?
Would an old guy (75) who is proficient in Obj-C, only codes for iOS/macOS/tvOS/web, and has spent the last 60 years promising himself “that’s definitely the last language I’m learning”, now find it pleasing/beneficial/productive to learn Swift/SwiftUI? Assume programming is relegated to a hobby and favorite pastime and I’ll live 10 more years :) Thanks.
5
0
7.5k
Jul ’26
Is NavigationSplitView on macOS 27 broken?
On macOS 27 Beta 2, a simple NavigationSplitView example exhibits bizarre behaviour when the window is resized. The sidebar seemingly expands and collapses at random as the window is resized. The symptoms can be exacerbated with toolbar items. The sidebar appears to behave correctly when an inspector view is not present. Copy paste the code below into a new Xcode 27 project and run on macOS 27 and then resize the window: File -> New -> Project... -> App import SwiftUI @main struct MyApp: App { var body: some Scene { WindowGroup { ContentView() } } } struct ContentView: View { var body: some View { NavigationSplitView { Text(Sidebar) } detail: { Text(Content) } .inspector(isPresented: .constant(true)) { Text(Inspector) } } } Adding .frame or .inspectorColumnWidth to any of the Text views does not appear to fix the issues. macOS: 27.0 Beta (26A5368g) Xcode: 27.0 beta 2 (27A5209h)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
3
0
395
Jul ’26
Reply to Pass data to an @Observable model
@ChrisDE Questions Should CarDetailViewModel be created in CarDetailView? Or should CarDetailViewModel be created in ContentView and passed to CarDetailView? Code ContentView struct ContentView: View { @State private var selectedCarID: UUID? var body: some View { NavigationSplitView { CarListView(selectedCarID: $selectedCarID) } detail: { if let selectedCarID { CarDetailView(carID: selectedCarID) } } } } CarListViewModel @Observable class CarListViewModel { let cars = [ Car(id: UUID(), name: aaa), Car(id: UUID(), name: bbb) ] } CarListView import SwiftUI struct CarListView: View { @Binding var selectedCarID: UUID? @State var model = CarListViewModel() var body: some View { List(model.cars, selection: $selectedCarID) { car in VStack(alignment: .leading) { Text(car.name) Text((car.id)) } } } } CarDetailViewModel @Observable class CarDetailViewModel { let carID: UUID init(carID: UUID) { self.carID = carID } } CarDetailView import SwiftUI struct CarDetailView: View { @State private var model: Ca
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’26
Reply to Bug: Xcode 26.2 wants `ENABLE_DEBUG_DYLIB`: How do I enable that in `Package.swift`?
Unfortunately, SwiftPM does not inherit Xcode's build settings at all from a containing project. And there is no way to specify any Xcode build setting in a package manifest. Specifying an executable target with SwiftUI in a package is an interesting case. If I were in your shoes, I'd just pull everything out into another module target in the package and have the executable depend on it. Previewing in that module will work just fine. All the executable needs is the @main entry point. It doesn't need the views or previews to be in that target.
Replies
Boosts
Views
Activity
Jul ’26
Reply to Bug: Xcode 26.2 wants `ENABLE_DEBUG_DYLIB`: How do I enable that in `Package.swift`?
I have an executable SwiftUI target in my swift package, and have run into this error also - Previews requires ENABLE_DEBUG_DYLIB=YES to be defined. currently my package.swift has this: .executableTarget( name: ColorPickerDemo, dependencies: [ColorPicker], path: Sources/ColorPickerDemo, swiftSettings: [ .enableUpcomingFeature(ApproachableConcurrency), .define(ENABLE_DEBUG_DYLIB) ], linkerSettings: [ .unsafeFlags([ -Xlinker, -sectcreate, -Xlinker, __TEXT, -Xlinker, __info_plist, -Xlinker, Sources/ColorPickerDemo/Info.plist, ]), ] together with an info.plist for the executable, and the demo swiftui app can be launched. Clearly that isn't enough for previews though.. Any ideas?
Replies
Boosts
Views
Activity
Jul ’26
Reply to WidgetKit complications won't update
Data point from July 2026: this appears to work now - at least on current OS versions. Setup: iPhone companion (iOS 26.5) + SwiftUI-lifecycle watchOS app (watchOS 26.5) with WidgetKit accessory complications (no ClockKit) transferCurrentComplicationUserInfo() with a small dictionary payload (~6 keys), complication active on the watch face (isComplicationEnabled == true; the transfer budget was actually consumed: remainingComplicationUserInfoTransfers went 50 → 49 → 48 → 47) Both sides instrumented with file logging; every payload carries a monotonically increasing version, and we redundantly send the same update via updateApplicationContext as a fallback - so I can attribute exactly which channel applied each change Results - 3 consecutive sends while the watch was NOT reachable (isReachable == false on the phone at send time) and the watch app was backgrounded: sent 23:10:42.5 → didReceiveUserInfo on the watch at 23:10:57.6 (15.1 s). Ambiguous: the user happened to foreground the watch app ~150 ms b
Replies
Boosts
Views
Activity
Jul ’26
NavigationStack has no animations or back gesture in macOS
When running a native macOS app using SwiftUI and a NavigationStack, clicking any links causes the contents of the stack to change immediately with no animation, and you can't use the usual two-finger swipe gesture to go back. The behavior is correct when running it as a Mac Catalyst app, you get the animated transitions when navigating, and swiping works. Minimal Example: (put this directly inside the WindowGroup) NavigationStack { VStack { NavigationLink { Rectangle().foregroundStyle(.red) } label: { Text(Button) } } }
Replies
1
Boosts
0
Views
373
Activity
Jul ’26
Reply to iPadOS extended display architecture
This is very interesting post hope I understand correctly what you trying to accomplish, and more about when talking about MultipleScenes and moving Scenes to external displays. To build a native iPadOS application that utilizes an external display with custom layouts while preserving pointer interaction, you must adopt a Multi-Scene Architecture. But hope other developers also provide their solution here. https://developer.apple.com/documentation/swiftui/scene Treats the external display as an extended desktop. Fully preserves native pointer interaction, hover effects, and custom interactive layouts. You cannot force the window to open full-screen on the external display automatically; the OS or the user dictates window placement, though you can programmatically request a new scene. Because your app will effectively run two independent UI hierarchies (one on the iPad, one on the external display), your architecture must strictly separate UI from state. https://developer.apple.com/documentation/uikit
Topic: Design SubTopic: General Tags:
Replies
Boosts
Views
Activity
Jul ’26
Reply to Is NavigationSplitView on macOS 27 broken?
Following up to say that this remains broken in macOS 27 beta 3. macOS 27.0 Beta (26A5378j) Xcode 27.0 beta 3 (27A5218g) Open Xcode, File -> New Project, macOS SwiftUI app and copy paste the code above and then run.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jul ’26
Reply to SwiftUI Slider onEditingChanged is unreliable on iOS 26
Has anyone found a workaround or solution? I'm seeing this behavior in Xcode 26.6 (17F113) and MacOS 26.5.2., even with Apple's own example code. import SwiftUI struct SliderViewTest: View { @State private var speed = 50.0 @State private var isEditing = false var body: some View { VStack { Slider( value: $speed, in: 0...100, step: 5 ) { Text(Speed) } minimumValueLabel: { Text(0) } maximumValueLabel: { Text(100) } onEditingChanged: { editing in isEditing = editing } Text((speed)) .foregroundColor(isEditing ? .red : .blue) } } } #Preview { SliderViewTest() .padding() }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jul ’26
Reply to Learn Swift and SwiftUI in my old age?
[quote='836918021, pabugeater2, /thread/836918, /profile/pabugeater2'] find it pleasing/beneficial/productive to learn Swift/SwiftUI? [/quote] Let’s break that down: Pleasing That’s very much gonna depend on you. Beneficial Yes. Regardless of any other factors, there’s solid evidence that learning new stuff is beneficial, especially as you get older. Productive That kinda depends on what you intend to produce (-: As someone who’s not exactly young myself, I’ve started to understand that the time I have left is limited, and that I need to focus on what I enjoy. I absolutely love playing around with computers, so if and when I retire there’s no doubt I’ll continue doing that. Keep in mind that there’s a middle ground, namely using Swift to call the frameworks you already know. If you get pleasure from shipping stuff, that might be a good first step, rather than wrestling with Swift and SwiftUI at the same time. Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myE
Replies
Boosts
Views
Activity
Jul ’26
How can a SwiftUI drag provide the actual file URL of an existing file on macOS (as NSOutlineView does)?
I'm dragging existing files from a SwiftUI List (a search result list in a sandboxed, document-based Mac app), and I want drop targets to receive the actual file URL — the same behavior as AppKit's NSOutlineView with outlineView(_:pasteboardWriterForItem:) returning an NSURL: the Finder copies the file, browsers load it, and text views insert its path. My current implementation is Transferable-based: FileRepresentation(exportedContentType: .data) { item in SentTransferredFile(item.fileURL, allowAccessingOriginalFile: true) } .suggestedFileName(.fileURL.lastPathComponent) With this, what receivers get is a temporary copy in the app's own container (Caches/com.apple.SwiftUI.Drag-/), not the actual file URL — despite allowAccessingOriginalFile: true. Dropping on the Finder or onto an application icon works through the copy, but receivers that interpret the URL itself — a browser window, or a text view that inserts the dropped file's path — see the temporary container path. Note that the dragged files li
Replies
3
Boosts
0
Views
429
Activity
Jul ’26
Reply to Code Signing (I think)
Can you try running on the simulator instead of on a real device? If you are starting new: Learn swift (https://docs.swift.org/swift-book/documentation/the-swift-programming-language/) Learning iOS development (https://cs193p.stanford.edu) - Use this as a guidance, then once you are comfortable with the basics then refer to Apple documentation / WWDC videos Learn SwiftUI (WWDC videos are pretty good)
Topic: Code Signing SubTopic: General
Replies
Boosts
Views
Activity
Jul ’26
Reply to Learn Swift and SwiftUI in my old age?
Last year, at age 73, I decided to switch my hobby programming to Swift/SwiftUI from XOJO. I waited for SwiftUI to mature as UIKit made my eyes glaze over. After about 6 months of grinding, I successfully converted one of my XOJO apps. I now know there's a few things I did sub-optimally, so I'm continuing to learn. Jump in, the water's fine.
Replies
Boosts
Views
Activity
Jul ’26
Code Signing (I think)
Just started learning SWIFT. How come this code (in a separate file): // // indexLoader.swift // PhotoViewer // // Created by Bruce Quimby on 7/3/26. // import SwiftUI import SwiftData struct LoadIndex { let indexURL = https://Some URL; func getIndex() { print(The next step will be to get the index from this URL: + indexURL); } } makes my build fail with: Cannot create a iOS App Development provisioning profile for Just-Me.PhotoViewer.Retrieve-Index. Personal development teams, including ME, do not support the Accessory Setup Extension capability.
Topic: Code Signing SubTopic: General
Replies
2
Boosts
0
Views
480
Activity
Jul ’26
Learn Swift and SwiftUI in my old age?
Would an old guy (75) who is proficient in Obj-C, only codes for iOS/macOS/tvOS/web, and has spent the last 60 years promising himself “that’s definitely the last language I’m learning”, now find it pleasing/beneficial/productive to learn Swift/SwiftUI? Assume programming is relegated to a hobby and favorite pastime and I’ll live 10 more years :) Thanks.
Replies
5
Boosts
0
Views
7.5k
Activity
Jul ’26
Is NavigationSplitView on macOS 27 broken?
On macOS 27 Beta 2, a simple NavigationSplitView example exhibits bizarre behaviour when the window is resized. The sidebar seemingly expands and collapses at random as the window is resized. The symptoms can be exacerbated with toolbar items. The sidebar appears to behave correctly when an inspector view is not present. Copy paste the code below into a new Xcode 27 project and run on macOS 27 and then resize the window: File -> New -> Project... -> App import SwiftUI @main struct MyApp: App { var body: some Scene { WindowGroup { ContentView() } } } struct ContentView: View { var body: some View { NavigationSplitView { Text(Sidebar) } detail: { Text(Content) } .inspector(isPresented: .constant(true)) { Text(Inspector) } } } Adding .frame or .inspectorColumnWidth to any of the Text views does not appear to fix the issues. macOS: 27.0 Beta (26A5368g) Xcode: 27.0 beta 2 (27A5209h)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
3
Boosts
0
Views
395
Activity
Jul ’26
Reply to Pass data to an @Observable model
@ChrisDE Questions Should CarDetailViewModel be created in CarDetailView? Or should CarDetailViewModel be created in ContentView and passed to CarDetailView? Code ContentView struct ContentView: View { @State private var selectedCarID: UUID? var body: some View { NavigationSplitView { CarListView(selectedCarID: $selectedCarID) } detail: { if let selectedCarID { CarDetailView(carID: selectedCarID) } } } } CarListViewModel @Observable class CarListViewModel { let cars = [ Car(id: UUID(), name: aaa), Car(id: UUID(), name: bbb) ] } CarListView import SwiftUI struct CarListView: View { @Binding var selectedCarID: UUID? @State var model = CarListViewModel() var body: some View { List(model.cars, selection: $selectedCarID) { car in VStack(alignment: .leading) { Text(car.name) Text((car.id)) } } } } CarDetailViewModel @Observable class CarDetailViewModel { let carID: UUID init(carID: UUID) { self.carID = carID } } CarDetailView import SwiftUI struct CarDetailView: View { @State private var model: Ca
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jul ’26