On any project that I open or create from scratch (SwiftUI) the "prebuild" that gets kicked off never finishes which results in the fact that I can not build the project.
If I use XCode 16 beta 2 everything works fine.
Post
Replies
Boosts
Views
Activity
Swift Chats chartScrollTargetBehavior is not working correctly when domain count is relatively small
I’m seeing a strange behavior when using chartScrollTargetBehavior and trying to scroll to a majorAlignment (.matching(DateComponents(day: 1))).
let numberOfBarMarks = 10
.chartXVisibleDomain(length:3600 * 24 * numberOfBarMarks)
.chartScrollTargetBehavior(
.valueAligned(
matching: DateComponents(hour: 0),
majorAlignment: .matching(DateComponents(day: 1)))
)
)
The issue is fully reproducible.
I believe the issue is related to the number of bar marks being displayed in a domain. If I use 10 then the issue shows up, if I use 30 the issue doesn’t happen.
Filed as FB13889037 including video and sample code.
Hi Quinn,
I have a macOS App (SwiftUI) which scans for available WifiNetworks using
CWWiFiClient.shared().interface().scanForNetworks(withSSID: nil)
The app is sandboxed and has "Outgoing Connections" (Client) checked.
The app is Launched via a "LaunchAgents".
During app init() I kickoff the scanForNetworks in a background thread. I do receive WifiNetworks but when I look at the SSID quite often all of the SSIDs are nil.
If I loop the scanForNetworks() a few times with a delay of 1 second after a few tries the SSIDs will no longer be nil.
Any idea why this happens?
Should I file a bug report or is that expected behavior
Thanks very much,
Martin (your old friend from Germany)
Does anyone know of to get the currently visible data items in chart (e.g. BarMarks) on iOS 17 when using chartScrollableAxes.
From the WWDC23 video of session "Explore pie charts and interactivity in Swift Charts" at time 8:18 you see that the "Total sales" lists the visible time frame (e.g. May 4 - June 4, 2023) and a few seconds late when the chart scrolls the values do update.
When using the new iOS “chartScrollableAxes” feature annotation that should show on top of the chart view no longer work. When disabling “chartScrollableAxes” everything works again.
Filed as FB12584128
import SwiftUI
import Charts
class ChartDataEntry:Identifiable {
var date:Date
var value:Double
init(date:Date, value: Double) {
self.date=date
self.value=value
}
}
struct ContentView: View {
@State var rawSelectedDate: Date?
var chartData = [ChartDataEntry(date: Date().yesterday.yesterday.yesterday.yesterday.startOfDay, value: 10.0),
ChartDataEntry(date: Date().yesterday.yesterday.yesterday.startOfDay, value: 20.0),
ChartDataEntry(date: Date().yesterday.yesterday.startOfDay, value: 30.0),
ChartDataEntry(date: Date().yesterday.startOfDay, value: 40.0),
ChartDataEntry(date: Date().startOfDay, value: 50.0)]
var body: some View {
VStack {
Chart(chartData) { entry in
BarMark(
x: .value("Day", entry.date, unit: .day),
y: .value("Values", entry.value)
)
if let selectedDate {
RuleMark( x: .value("Selected", selectedDate, unit: .day))
.foregroundStyle(Color.gray.opacity(0.3))
.offset(yStart: -10)
.zIndex(-1)
.annotation(position: .top, spacing: -10,
overflowResolution: .init(
x: .fit(to: .chart),
y: .disabled
)
) {
Text("Longer Sample Text")
}
}
}
.chartScrollableAxes(.horizontal) // <<--- when this is disabled the annotation will be shown correctly
.chartXSelection(value: $rawSelectedDate)
.frame(height: 300)
}
.padding()
}
var selectedDate: Date? {
guard let rawSelectedDate else { return nil }
return chartData.first(where: {
let endOfDay = $0.date.endOfDay
return ($0.date ... endOfDay).contains(rawSelectedDate)
})?.date
}
}
#Preview {
ContentView()
}
extension Date {
var yesterday: Date {
return Calendar.current.date(byAdding: .day, value: -1, to: self)!
}
var startOfDay: Date {
return Calendar.current.startOfDay(for: self)
}
var endOfDay: Date {
var components = DateComponents()
components.day = 1
components.second = -1
return Calendar.current.date(byAdding: components, to: startOfDay)!
}
}
I like to have a scrollable chart with chartXSelection. How can that be accomplished?
As soon as I have .chartXSelection the chart doesn't really scroll any more. I'm looking for some sort of delayed chartXSelection gesture, where the chartXSelection kicks in after a short delay of 1-2 seconds.
The Apple Heath App does support this very nicely.