Post

Replies

Boosts

Views

Activity

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).
Topic: UI Frameworks SubTopic: SwiftUI Tags:
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).
Topic: UI Frameworks SubTopic: SwiftUI Tags:
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.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
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
Topic: UI Frameworks SubTopic: SwiftUI Tags:
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
Reply to Questions Tags Saves Users Companies Labs Jobs Discussions Collectives Communities for your favorite technologies. Explore all Collectives Teams Now available on Stack Overflow for Teams! AI features where you work: search, IDE, and chat. Lookin
Welcome to the forum. Your question is not about app development. So you'd better ask on Apple Support Community: https://discussions.apple.com/welcome PS: make the titles of your posts shorter and more explicit. Title is not to tell a full story. Read advice #13: https://developer.apple.com/forums/thread/706527
Topic: Safari & Web SubTopic: General
Oct ’24