Post

Replies

Boosts

Views

Activity

Reply to preferredColorScheme not working with Xcode 16
@GRALInfo Thanks for this additional testing. Using AppStorage (for a simple Bool) was an early design decision as the property isDarkMode is used in many views. So I could effectively use an environment variable and initialise in .onAppear or in an init(). I'll go this way if the bug is not corrected (I now definitely think it is an Xcode 16 regression). But falling on such issues in development environment is making me a bit nervous, wondering what else may be broken ? @VisionPro Thanks for the link. It is another way of doing it, but that denies the simplicity of AppStorage. If it is not corrected in a future Xcode release, does it mean that AppStorage is on obsolescence path ?
Oct ’24
Reply to preferredColorScheme not working with Xcode 16
@GRALInfo, thanks for the test and the information. Effectively that could be an incompatibility with MacOS < 15. Which nevertheless is an issue, if we cannot keep the apps running correctly on not so older OS versions. To fully assess the point, would you have the opportunity to test the app produced by Xcode 16 on an older OS ? I'll post the answer if I get from FB.
Oct ’24
Reply to preferredColorScheme not working with Xcode 16
I created a minimal project in Xcode 15.3 to reproduce the issue (run on MacOS 14.7). When compiled with Xcode 15.3, the toggle switches from light to dark mode. When compiled with Xcode 16 (16.0 or 16.1ß3), the toggle has no effect. I attached the complete project to FB report. import SwiftUI @main struct DarkModeTest_MacApp: App { @AppStorage("isDarkMode") private var isDarkMode = false var body: some Scene { WindowGroup { ContentView() .frame( minWidth: 300, maxWidth: .infinity, minHeight: 200, maxHeight: .infinity) .preferredColorScheme(isDarkMode ? .dark : .light) } .windowResizability(.contentSize) } } import SwiftUI struct ContentView: View { @AppStorage("isDarkMode") private var isDarkMode = false var body: some View { VStack { Image(systemName: "globe") .imageScale(.large) .foregroundStyle(.tint) Text("Hello, world!") Button(action: { isDarkMode.toggle() }) { Text("Toggle") } } .padding() } } #Preview { ContentView() } Additional information: It works on iPad (simulator).
Oct ’24
Reply to preferredColorScheme not working with Xcode 16
I tried with 16.1ß3, same issues. However, if I set the background manually on a view (with colors that mimic the preferredScheme), it works: .background(isDarkMode ? Color.veryDarkGray : `Color.lightGray)` But having to do it on any subview is not a viable solution. So for the time being I stay with 15.3, but that's not a sustainable option either. Could it be a compatibility issue between Xcode 16.x and MacOS 14.y ?   Also, are you able to try with macOS 15.1? This is a Mac app, right? I cannot try with MacOS 15 at this time. And in any case, app has to run on versions below (down to MacOS 12 in fact), so that would not solve the problem. The app (SwiftUI) runs on MacOS and iOS I also tested the app by setting the Mac to dark mode. App does not adapt to dark. So it is just as if, with Xcode 16, preferredColorScheme was ignored. Could it come from AppStorage (but once again, it worked in Xcode 15).
Oct ’24
Reply to preferredColorScheme not working with Xcode 16
I tried to change the colorScheme as exposed here: https://stackoverflow.com/questions/61912363/swiftui-how-to-implement-dark-mode-toggle-and-refresh-all-views Or to create a State var from the AppStorage… But I understood that AppStorage is already a State var, so that should not be needed. To no avail. The View background remains unchanged but some subviews get changed… And anyway, that would not explain the difference between Xcode 15 and 16… Tested in Xcode 16.1ß1 without success.
Oct ’24
Reply to SwiftUI conditional modifier depending on OS type and version
I found a simple answer here: https://stackoverflow.com/questions/74300019/how-to-use-if-available-in-main-in-a-documentgroup-application Just enclose in a func: struct TheApp: App { var body: some Scene { conditionalScene() } #if os(macOS) func conditionalScene() -> some Scene { if #available(macOS 13.0, *) { WindowGroup { ContentView() .frame( minWidth: 1200, maxWidth: .infinity, minHeight: 600, maxHeight: .infinity) } .windowResizability(.contentSize) // Only here } else { WindowGroup { ContentView() .frame( minWidth: 1200, maxWidth: .infinity, minHeight: 600, maxHeight: .infinity) } } } #else // iOS func conditionalScene() -> some Scene { if #available(iOS 17.0, *) { WindowGroup { ContentView() .frame( minWidth: 1200, maxWidth: .infinity, minHeight: 600, maxHeight: .infinity) } .windowResizability(.contentSize) // Only here } else { WindowGroup { ContentView() .frame( minWidth: 1200, maxWidth: .infinity, minHeight: 600, maxHeight: .infinity) } } } #endif // test of OS } // App
Oct ’24
Reply to WhatsApp iso 18.1
Welcome to the forum. Your question is not about app development. So you'd better either contact Whatsapp or Facebook on their forum, as it looks like a WhatsApp bug: https://www.reddit.com/r/whatsapp/comments/1ftr4rw/ios_18_car_play_and_whatsapp_issues/ ask on Apple Support Community: https://discussions.apple.com/welcome file a bug report here: https://feedbackassistant.apple.com (but it does not look like an iOS bug). PS: I hope you don't use it when driving. In that case it's safe not to let you answer 😉
Oct ’24