Same here on Version 15.0.1 (15A507). I was able in the morning and then in the evening on a different build got that message. The only think that changed in my build was using an
if #available(iOS 17, *) clause.
Post
Replies
Boosts
Views
Activity
@arno_app here's how I remediated this issue using the SwiftUI overlay with gradient approach. The trick was in using also * .listItemTint** (Still disappointed that this bug was not caught before launching in Watch OS 10 and had to add all this extra code). Hope this helps!
TextField(...)
.listRowInsets(DrawingConstants.zeroPadding)
.listItemTint(DrawingConstants.listItemTint) // THIS IS THE TRICK FOR WATCHOS 10
.overlay {
HStack(spacing: 0) {
Spacer()
Rectangle()
.fill(DrawingConstant.gradient)
.frame(maxWidth: DrawingConstants.spacingWidth, maxHeight: .infinity)
Button(...)
.buttonStyle(.borderless)
.frame(maxHeight: .infinity)
.background(DrawingConstants.overlayBackground)
}
.clipShape(RoundedRectangle(cornerRadius: DrawingConstants.clearButtonRadius))
}
...
struct DrawingConstants {
static let overlayBackground: Color = ... red: 31, green: 31, blue: 31
static let listItemTint = {
if #available(watchOS 10, *) {
return Color.clear
} else {
return DrawingConstants.overlayBackground
}
}()
static let spacingGradient = LinearGradient(gradient: Gradient(colors: [.clear, DrawingConstants.overlayBackground]), startPoint: .leading, endPoint: .trailing)
...
}
Same for me, with similar code that I use for a clearable TextField for iOS and Watch OS. I couldn't find a workaround because the background is added as an alpha visual effect in TextField itself and could not be overwritten or even blended.
HStack {
TextField(...)
Spacer()
Button(...)
}
If I still want this to look decent in WatchOS 10 looks like I'll need to experiment with an overlay and alpha gradient for text blending which pretty much defeats the purpose and magic of SwiftUI of reusing views between platforms and OS versions.
Issue is still present in Xcode 15, it's easily reproducible if importing the Lottie framework via SPM in an iOS project with a companion Watch app. This just messes Xcode Previews for the Watch app view.
My "Watch App" target never includes Lottie as dependency, just the "iOS App". Both build correctly and load on Simulator devices. But fails on Apple Watch Preview, which out of nowhere assume Lottie is a dependency for the "Watch App" even though it's not added on the target scheme. #frustrating
==PREVIEW UPDATE ERROR:
SchemeBuildError: Failed to build the scheme ”Watch App”
While building for watchOS Simulator, no library for this platform was found in '/Users/.../SourcePackages/artifacts/lottie-spm/Lottie/Lottie.xcframework'. (in target 'Lottie' from project 'Lottie')
Build target Lottie:
Same Xcode 15 official release here and even without using Previews or Simulators but just Xcode open I had 2 SpringBoards at +100% CPU melting my computer.
According to Google Bard 🤖 this can happen if you are using an ObservableObject @Published property as the path: Binding on a NavigationStack and you are changing the value of the property in the same frame.
⚠️ Something like this triggered the runtime warning for me, despite everything still working properly:
// ViewModel
class MyModelObject: ObservableObject {
@Published var path: [MyObject] = []
...
}
// View
@StateObject var model = MyModelObject()
var body: some View {
NavigationView(path: $model.path) {
...
✅ In the end, the following fixed the runtime warning, I had to make path: read from a @State property Binding and still communicate to the view model using the onChange function.
// ViewModel
class MyModelObject: ObservableObject {
@Published var path: [MyObject] = []
...
// Useful for manipulating a property observed by other components.
func update(_ path: [MyObject]) {
self.path = path
}
}
// View
@State var presentedPath: [MyObject] = []
@StateObject var model = MyModelObject()
var body: some View {
NavigationView(path: $presentedPath) {
...
}.onChange(of: presentedPath) { newPath in
model.update(path: newPath)
}
}