Hi, I have the exact same issue and I cannot figure our why it occurs. Do you have a solution to it? I would not like to strip out all JSONDecoder calls
Post
Replies
Boosts
Views
Activity
I was looking for the same option. I tried setting a fixed width by using a geometry reader.
GeometryReader { geo in
NavigationView {
List()
.frame(minWidth: geo.size.width/3)
}
}
This does actually change the width, but the origin of the view moves out to the left. You can change the position, but then the view will be cropped on the right. The actual width of the main navigation view does not change
Did you have any luck changing this? Setting it in the hosting controller does not seem to have any effect
This issue persists on watchOS 8 Beta. It's not just that the onChange is not called. It is also not updating the variable at all (in some cases). As this seems to be unreliable I went for this solution, which is not recommended, but 100% reliable:
1. Create an ExtensionDelegate / AppDelegate
It just serves to send notifications when the state of the app changes. For watchOS this would be:
class ExtensionDelegate: NSObject, WKExtensionDelegate {
func applicationDidBecomeActive() {
NotificationCenter.default.post(name: Notification.Name.App.scenePhaseChanged, object: nil, userInfo: ["scenePhase": ScenePhase.active])
}
func applicationWillResignActive() {
NotificationCenter.default.post(name: Notification.Name.App.scenePhaseChanged, object: nil, userInfo: ["scenePhase": ScenePhase.inactive])
}
func applicationDidEnterBackground() {
NotificationCenter.default.post(name: Notification.Name.App.scenePhaseChanged, object: nil, userInfo: ["scenePhase": ScenePhase.background])
}
}
2. Create a custom ScenePhase environment key
This serves as a replacement for the actual key, which is not updated reliably.
extension EnvironmentValues {
var customScenePhase: ScenePhase {
get {self[CustomScenePhaseKey.self]}
set {self[CustomScenePhaseKey.self] = newValue}
}
}
private struct CustomScenePhaseKey: EnvironmentKey {
static let defaultValue = ScenePhase.inactive
}
3. Process updating notifications with the new scenePhase
var appStateChangeNotification = NotificationCenter.default.publisher(for: Notification.Name.App.scenePhaseChanged)
//....
.onReceive(self.appStateChangeNotification, perform: { notification in
let newScenePhase: ScenePhase = notification.userInfo?["scenePhase"] as? ScenePhase ?? .active
guard newScenePhase != self.scenePhase else {return}
self.scenePhase = newScenePhase
})
4. Forward the new scenePhase
ContentView()
.environment(\.customScenePhase, self.scenePhase)
I hope this sample code helps anyone with similar issues
I have seen a similar issue with my released application.
When a user starts an ASWebAuthenticationSession Chrome does not fulfill the authentication session at all.
It does not even open the website that it should open.
I think ASWebAuthentication should default to Safari just to make sure that it works
The answer I found to this is not really satisfying, but it works fine with SwiftUI.
Every time the variable isLuminanceReduced changes, the ExtensionDelegate also changes the app state and calls applicationWillResignActive().
So to keep backwards compatible I introduced a singleton class that just holds a Bool isOn:
class LuminanceReducedCompat: ObservableObject {
@Published var isOn: Bool = false
public static let shared = LuminanceReducedCompat()
private var notifcationObservers = [Any]()
private init() {}
}
Now you can change the isOn variable in the applicationWillResignActive().
On your SwiftUI views you can add a that object now as an observed object.
@ObservedObject var luminanceReducedCompat = LuminanceReducedCompat.shared
I know that's not really nice, but the best I found until now. I don't want to maintain 2 views that show the same.
I though about using a custom Environment Value that reflects the official watchOS 8 value, but I am not sure how to push this into the view stack correctly and update it.
I did a bunch of testing, like setting the target back to watchOS 7 and 6 and it still worked.
Then I deleted and completely reinstalled the app with watchOS 6 as a deployment target and it kept working.
So I guess that the main issue here might be an issue during an update. So that after an update the watch does not recognize that the app is always-on capable, but after reinstallation it does so.
Hopefully the same issue does not occur with App Store updates
Seems to continue in watchOS 8.
I have filed feedback about this with the release of watchOS 7 already. (FB9055341)
EDIT: On Stackoverflow I found out that this issue is actually due to a SwiftUI change.
The title of a sheet on watchOS is no longer an actual title, but a button in a toolbar. To change it you can overwrite the toolbar:
MySheet().toolbar {
ToolbarItem(placement: .cancellationAction) {
Button(title, action: action)
}
}
In the action you can use the environment value for presentationMode to close the sheet.
The button will be clickable and it will replace the cancel title.
So this is more a documentation and restructuring issue that almost no one caught.
Source: https://stackoverflow.com/a/64194674/1203713
I had the same issue. I could fix it by setting the Xcode-select to the Xcode-beta version. Now for me all the AppIntents appear in the shortcuts app.
When you want to create an AppShortcut, you should omit custom AppEntity based parameters from the phrases. Otherwise, they don't appear in the shortcuts app and are not usable by Siri. This is likely a bug and I already filed feedback for it.
I discovered that it's possible the developer token directly with try await MusicDataRequest.tokenProvider.developerToken(options: []). Unfortunately, this returns another error:
Encountered error while requesting developer token. Error Domain=ICError Code=-7010 "Failed to get listener endpoint for cloud service status monitor." UserInfo={NSDebugDescription=Failed to get listener endpoint for cloud service status monitor....
This was a crash caused by Xcode 14.3. When compiling with 14.3 and using Objective-C protocols in Swift the produced binary could not run on watchOS 6 and iOS 13.
The solution here is to use Xcode 14.3.1, which fixes the bug.
Luckily that seems to be a bug that has been fixed on the RC of the watch simulator. I updated and all logs are outputted as expected.
The best way to test it, is to activate "Type to Siri" in the accessibility settings. This also works for the watch simulator.
The issue that Siri will not pick up your voice is still existent with Xcode 15.
I managed the solve this issue by
Unpair watch and iPhone from Xcode (right-click).
Quit Xcode and disconnect the iPhone (Airplane mode)
Remove trusted computers on both devices.
Disable developer mode
Restart both devices.
Connect the iPhone and trust the computer using Finder
Open Xcode and pair the iPhone (trust again)
Enable developer mode on watch and iPhone
It should work.
This was basically following the advice in this post + unpairing the devices from Xcode:
https://forums.developer.apple.com/forums/thread/734694?page=2