Post

Replies

Boosts

Views

Activity

scrollClipDisabled not support Form
Apple introduced a new API scrollClipDisabled to disable clip in List. But it dose not work in Form. What should I do if I want to disable the clip action and show the shadow? Or maybe scrollClipDisabled should support Form too? NavigationStack { Form { Section { Picker("播放速度", selection: $playSpeed) { ForEach(speeds, id: \.self) { speed in Text(String(speed)) } } Picker("最高画质", selection: $mediaQuality) { ForEach(MediaQualityEnum.allCases, id: \.self) { speed in Text(speed.desp) } } Toggle("Hevc优先", isOn: $preferHevc) Toggle("无损音频和杜比全景声", isOn: $losslessAudio) } header: { Text("播放器") } } .scrollClipDisabled() // not work }
1
0
651
Aug ’23
Compare @FocusState will trigger change of it's value
I found a weird problem when I use @FocusState. I need to compare the value of @FocusState and display different View. But I found that compare @FocusState will trigger a change of it's value. The code blow will display two list of buttons. When you select the 2 button in the first list, the right button will display. When I try to move to the right button, the focus will jump to the 1 button in the first list. The reason is focused was changed to 1 when I try to jump to the right button(the value of focused will be nil and then 1). And if I remove the compare code(if focused == 2), it will work fine. I am currently using Xcode beta 6. Not sure if it is a bug in beta version. struct Demo: View { @FocusState var focused: Int? var body: some View { HStack { List { ForEach((1...10), id: \.self) { number in Button { } label: { Text("\(number)") } .focused($focused, equals: number) } } List { if focused == 2 { Button { } label: { Text("Button") } } } } } }
0
0
649
Aug ’23
SwiftUI: Change the button color in hover
I want to use the default button style, and I know we can set the tint to change the background color of a button. But how can I change the color when user hover the button, in macOS or tvOS? The hover button color is still a white with a transparency even it shows other color when not in hover.
1
0
2.2k
Dec ’23
Can not create a View with generic inside an other View
I tried to create a View with generic inside an other View, and it works fine with build and run. But when I tried to review it, Xcode 15.1 showed an error. CompileDylibError: Failed to build AView.swift Compiling failed: cannot find 'SubListView' in scope struct AView: View { struct BView<T: DisplayData>: View { } } I need to move the BView out of AView to fix the issues. I think it is a preview bug as it works well on build and run.
1
0
464
Dec ’23
Set value to @State in init function
I want to pass a value to a property marked with @State, and it doesn't work. struct AView: View { @State private var content: String? var body: some View { Text(content ? "") } init(content: String) { self.content = content } } #Preview { AView(content: "Test") } But if I change the content to non optional, it works well. struct AView: View { @State private var content: String var body: some View { Text(content) } init(content: String) { self.content = content } } #Preview { AView(content: "Test") } I googled for a while and found that I need to use a spacial way to initialize @State property in the first case. init(content: String) { _content = State(initialValue: content) } It works, but why? Is there any difficulty to unified API between optional and non optional @State property?
0
0
482
Dec ’23
Import DocC to Xcode
I'm trying to figure out how to build DocC from other frameworks to Xcode's Developer Documentation. I tried using the build documentation command, and it generates the DocC for my project and displays it in the Developer Documentation, but not libraries in the SPM. The code documentation does appear in the Developer Documentation, but the contents of the DocC are not shown.
2
0
990
Jun ’24
Markdown openURL can not handle property url
I'm trying to render a markdown with a link using Text. If the URL of the link is a static string, then no problem. If the URL is a property, then OpenURLAction gets a string ‘%25@’. I think this may be a bug. struct ContentView: View { let url = "https://www.google.com" var body: some View { Text("[Terms of Service](\(url))") .environment(\.openURL, OpenURLAction(handler: { url in print(url) return .handled })) } }
2
0
121
Mar ’25
Debug Failed in Xcode Simulator
I can‘t use breakpoints on the simulator after updating Xcode and the simulator. I can use breakpoints on a physical iPhone. I tired to download other iOS simulator version, but still not working. Both SwiftUI and UIKit not working. Xcode version: 16.2 SDK version: 18.2 (22C146) Simulator version: 18.3.1 (22D8075) Mac OS version: 15.4 Beta Couldn't find the Objective-C runtime library in loaded images. Message from debugger: The LLDB RPC server has crashed. You may need to manually terminate your process. The crash log is located in ~/Library/Logs/DiagnosticReports and has a prefix 'lldb-rpc-server'. Please file a bug and attach the most recent crash log.
49
63
16k
Apr ’25
Swift Chars chartYScale layout problem
I tried to narrow down the y-axis and use the clipped() to crop the excess. However, the clipped portion is too small, causing some of the chart to render above the x-axis. Is there any way to fix this, or any way to have the framework automatically set the y-axis range based on the data?
2
0
811
Nov ’25
tabBarMinimizeBehavior behavior in iOS 26
I'm trying to revamp the player into a floating style like Apple music. I use tabViewBottomAccessory with tabBarMinimizeBehavior. At the time, I noticed an issue that tabViewBottomAccessory would not automatically collapse when the scroll area was small (but still exceeded the screen height). tabViewBottomAccessory can only be automatically collapsed when the scroll area is large enough. Below is the simplest demo. I'm not sure if it's intentional or if it's a bug. Besides, I wonder if we can control it programmatically(expanded/inline)? struct ContentView: View { var body: some View { TabView { Tab("Numbers", systemImage: "number.circle") { List { // 200 works well, but 20 not ForEach(0..<200) { index in Text("\(index)") } } } } .tabBarMinimizeBehavior(.onScrollDown) .tabViewBottomAccessory { HStack { Text("SwiftUI Demo App") } } } }
1
0
170
Dec ’25
scrollClipDisabled not support Form
scrollClipDisabled seems only support ScrollView. I tried to add scrollClipDisabled to a Form but it did not work.
Replies
2
Boosts
0
Views
656
Activity
Jul ’23
scrollClipDisabled not support Form
Apple introduced a new API scrollClipDisabled to disable clip in List. But it dose not work in Form. What should I do if I want to disable the clip action and show the shadow? Or maybe scrollClipDisabled should support Form too? NavigationStack { Form { Section { Picker("播放速度", selection: $playSpeed) { ForEach(speeds, id: \.self) { speed in Text(String(speed)) } } Picker("最高画质", selection: $mediaQuality) { ForEach(MediaQualityEnum.allCases, id: \.self) { speed in Text(speed.desp) } } Toggle("Hevc优先", isOn: $preferHevc) Toggle("无损音频和杜比全景声", isOn: $losslessAudio) } header: { Text("播放器") } } .scrollClipDisabled() // not work }
Replies
1
Boosts
0
Views
651
Activity
Aug ’23
Compare @FocusState will trigger change of it's value
I found a weird problem when I use @FocusState. I need to compare the value of @FocusState and display different View. But I found that compare @FocusState will trigger a change of it's value. The code blow will display two list of buttons. When you select the 2 button in the first list, the right button will display. When I try to move to the right button, the focus will jump to the 1 button in the first list. The reason is focused was changed to 1 when I try to jump to the right button(the value of focused will be nil and then 1). And if I remove the compare code(if focused == 2), it will work fine. I am currently using Xcode beta 6. Not sure if it is a bug in beta version. struct Demo: View { @FocusState var focused: Int? var body: some View { HStack { List { ForEach((1...10), id: \.self) { number in Button { } label: { Text("\(number)") } .focused($focused, equals: number) } } List { if focused == 2 { Button { } label: { Text("Button") } } } } } }
Replies
0
Boosts
0
Views
649
Activity
Aug ’23
SwiftUI: Change the button color in hover
I want to use the default button style, and I know we can set the tint to change the background color of a button. But how can I change the color when user hover the button, in macOS or tvOS? The hover button color is still a white with a transparency even it shows other color when not in hover.
Replies
1
Boosts
0
Views
2.2k
Activity
Dec ’23
Can not create a View with generic inside an other View
I tried to create a View with generic inside an other View, and it works fine with build and run. But when I tried to review it, Xcode 15.1 showed an error. CompileDylibError: Failed to build AView.swift Compiling failed: cannot find 'SubListView' in scope struct AView: View { struct BView<T: DisplayData>: View { } } I need to move the BView out of AView to fix the issues. I think it is a preview bug as it works well on build and run.
Replies
1
Boosts
0
Views
464
Activity
Dec ’23
Set value to @State in init function
I want to pass a value to a property marked with @State, and it doesn't work. struct AView: View { @State private var content: String? var body: some View { Text(content ? "") } init(content: String) { self.content = content } } #Preview { AView(content: "Test") } But if I change the content to non optional, it works well. struct AView: View { @State private var content: String var body: some View { Text(content) } init(content: String) { self.content = content } } #Preview { AView(content: "Test") } I googled for a while and found that I need to use a spacial way to initialize @State property in the first case. init(content: String) { _content = State(initialValue: content) } It works, but why? Is there any difficulty to unified API between optional and non optional @State property?
Replies
0
Boosts
0
Views
482
Activity
Dec ’23
listRowSpacing support section
listRowSpacing only support the whole List, but sometimes we want to apply different spacing for different section in List.
Replies
1
Boosts
0
Views
696
Activity
Jun ’24
Import DocC to Xcode
I'm trying to figure out how to build DocC from other frameworks to Xcode's Developer Documentation. I tried using the build documentation command, and it generates the DocC for my project and displays it in the Developer Documentation, but not libraries in the SPM. The code documentation does appear in the Developer Documentation, but the contents of the DocC are not shown.
Replies
2
Boosts
0
Views
990
Activity
Jun ’24
"SwiftGenPlugin" is disabled in Xcode Cloud
My project uses a local swift package of my own, which uses SwiftGenPlugin to generate image resources. I can archive the project locally, but Xcode Cloud doesn't work and reports an error: "SwiftGenPlugin" is disabled.
Replies
0
Boosts
0
Views
322
Activity
Feb ’25
Markdown openURL can not handle property url
I'm trying to render a markdown with a link using Text. If the URL of the link is a static string, then no problem. If the URL is a property, then OpenURLAction gets a string ‘%25@’. I think this may be a bug. struct ContentView: View { let url = "https://www.google.com" var body: some View { Text("[Terms of Service](\(url))") .environment(\.openURL, OpenURLAction(handler: { url in print(url) return .handled })) } }
Replies
2
Boosts
0
Views
121
Activity
Mar ’25
Debug Failed in Xcode Simulator
I can‘t use breakpoints on the simulator after updating Xcode and the simulator. I can use breakpoints on a physical iPhone. I tired to download other iOS simulator version, but still not working. Both SwiftUI and UIKit not working. Xcode version: 16.2 SDK version: 18.2 (22C146) Simulator version: 18.3.1 (22D8075) Mac OS version: 15.4 Beta Couldn't find the Objective-C runtime library in loaded images. Message from debugger: The LLDB RPC server has crashed. You may need to manually terminate your process. The crash log is located in ~/Library/Logs/DiagnosticReports and has a prefix 'lldb-rpc-server'. Please file a bug and attach the most recent crash log.
Replies
49
Boosts
63
Views
16k
Activity
Apr ’25
Mergeable library is not compatible with SwiftUI preview
When I enable the Mergeable library in Xcode, SwiftUI preview will be not available, and the error is as follows. Cannot preview in this file Could not analyze the built target description for Demo to create the preview. arguments: -no_merge_framework: Failed parsing Mach-O file Assets Report
Replies
2
Boosts
0
Views
340
Activity
Sep ’25
Swift Chars chartYScale layout problem
I tried to narrow down the y-axis and use the clipped() to crop the excess. However, the clipped portion is too small, causing some of the chart to render above the x-axis. Is there any way to fix this, or any way to have the framework automatically set the y-axis range based on the data?
Replies
2
Boosts
0
Views
811
Activity
Nov ’25
Concurrency warning in Translation API
I encountered a concurrency compilation warning when calling the TranslationSession.translations(from: [TranslationSession.Request]) API, and I'm don't know how to resolve it. I reviewed the official demo, but it appears identical.
Replies
1
Boosts
0
Views
291
Activity
Dec ’25
tabBarMinimizeBehavior behavior in iOS 26
I'm trying to revamp the player into a floating style like Apple music. I use tabViewBottomAccessory with tabBarMinimizeBehavior. At the time, I noticed an issue that tabViewBottomAccessory would not automatically collapse when the scroll area was small (but still exceeded the screen height). tabViewBottomAccessory can only be automatically collapsed when the scroll area is large enough. Below is the simplest demo. I'm not sure if it's intentional or if it's a bug. Besides, I wonder if we can control it programmatically(expanded/inline)? struct ContentView: View { var body: some View { TabView { Tab("Numbers", systemImage: "number.circle") { List { // 200 works well, but 20 not ForEach(0..<200) { index in Text("\(index)") } } } } .tabBarMinimizeBehavior(.onScrollDown) .tabViewBottomAccessory { HStack { Text("SwiftUI Demo App") } } } }
Replies
1
Boosts
0
Views
170
Activity
Dec ’25