Hi, with iOS 17 creation of HKWorkout is deprecated via its init functions and the recommendation is to use HKWorkoutBuilder:
The problem is that I am creating this HKWorkout object inside unit tests in order to test a service that works with such objects. And HKWorkoutBuilder requires a HKHealthStore which itself requires to be authenticated to be able to create HKWorkoutActivity instances, like it would be when an app is running. But since the unit tests cannot accept the request on the HKHealthStore I am not sure if using HKWorkoutBuilder inside unit tests is possible.
Any ideas on how to proceed with creating HKWorkout for unit test purposes?
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Hi,
Since iOS 18 we now have a built-in "tap on item to scroll to the top" functionality into TabView, which is great but it does have a UI glitch on real devices, it works correct on simulators running from Xcode.
The real device I am testing is on iOS 18.2.1
It looks like this:
If I then try to scroll the list it snaps back to a offset bellow the navigation title, so fro the looks of it the "scroll to top" was not really to the top but some offset under it.
The View is declared like this:
struct ContentView: View {
private var tabSelection: Binding<String> { Binding(
get: { selectedTab },
set: { selectedTab = $0 }
)}
@State private var selectedTab: String = "Test"
var body: some View {
TabView(selection: tabSelection,
content: {
NavigationStack {
List {
ForEach(0...1000, id: \.self) { index in
Text("Test 1 - Row: \(index)")
}
}
.navigationTitle("Test 1")
}
.listStyle(.insetGrouped)
.tabItem {
Image(systemName: SFSystemName.morning)
Text("Test")
}
.tag("Test")
})
.tabViewStyle(.sidebarAdaptable)
}
}
Any ideas how to resolve this.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Since iOS 18 I have noticed a strange issue which happens to the TabView in SwiftUI when you switch from Dark to Light mode.
With this code:
import SwiftUI
struct ContentView: View {
var body: some View {
TabView {
List {
ForEach(0..<100, id: \.self) { index in
Text("Row: \(index)")
}
}.tabItem {
Image(systemName: "house")
Text("Home")
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
The TabBar does not switch colours when going from dark to light, it work correctly when going from light to dark.
Here is a video of iOS 18 with the issue:
Here is a video of iOS 17.5 with same code and no issue:
On real device it looks (better), the color does update but with delay.
I have submitted a feedback bug report, but in the meanwhile has anyone been back to resolve this?
Hi,
I am creating a custom NSSecureUnarchiveFromDataTransformer in order to handle attributes of entities of type NSDateComponents.
It all works and I did not see any warnings in the "Issue navigator" inside Xcode but with Xcode 15 I started seeing this warning:
/Users/.../CustomNSSecureUnarchiveFromDataTransformer/CoreData:1:1 no NSValueTransformer with class name 'CustomSecureUnarchiveFromDataTransformer' was found for attribute 'testDate' on entity 'Item'
My use case is very simple, I have this custom transformer:
@objc(CustomSecureUnarchiveFromDataTransformer)
final class CustomSecureUnarchiveFromDataTransformer: NSSecureUnarchiveFromDataTransformer {
override class var allowedTopLevelClasses: [AnyClass] {
return [NSDateComponents.self]
}
static let name = NSValueTransformerName(rawValue: String(describing: CustomSecureUnarchiveFromDataTransformer.self))
public static func register() {
let transformer = CustomSecureUnarchiveFromDataTransformer()
ValueTransformer.setValueTransformer(transformer, forName: name)
}
}
which is set to the Core data entity's "Transformer":
which leads to the warning in Xcode 15.
App works just fine and there are no problems during run time, but this warning is shown and I want to fix it.
Here is a simple test project https://github.com/VladimirAmiorkov/CustomNSSecureUnarchiveFromDataTransformer