Post

Replies

Boosts

Views

Activity

Reply to .onChange with ScenePhase not working
I had the same problem. Couldn't get this to work in the Simulator or on an iPhone running the iOS 14 beta. The ScenePhase doc's sample code didn't work for me when adding it to an App or Scene. Finally worked by adding it into the View instead (the first example in the ScenePhase doc). Seems more limited, but works. struct ContentView: View {     @Environment(\.scenePhase) var scenePhase     var body: some View {         Text("Hello, world!").padding()             .onChange(of: scenePhase) { phase in                 print("scenePhase change \(phase)")             }     } }
Jun ’20
Reply to macOS Swift UI App Life Cycle vs NSApplicationDelegate
Have you tried @NSApplicationDelegateAdaptor? I've only tested it briefly with applicationDidFinishLaunching(), but that method does get called. @main struct TestApp: App {   @NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate var body: some Scene {} } class AppDelegate: NSObject, NSApplicationDelegate {     func applicationDidFinishLaunching(_ notification: Notification) {         print("hello")     } }
Sep ’20
Reply to WeatherKit iOS SDK 401 network error
Just in case anyone else makes the same mistake I did. When adding the Bundle Identifier under Signing & Capabilities, somehow I had added it to the iOS section, but not to the field directly under Team (maybe because I added the BundleID before changing the Team to me?). I noticed this after reading through this post and going back to check if I had everything correct. I saw that there were 2 Bundle Identifier fields and the top one still had the Apple sample project BundleID. When I copied my BundleID to the field underneath Team, everything started working (& the 2nd Bundle Identifier field in the iOS section just disappeared).
Jun ’22
Reply to Xcode build crashes on: No such module '_SwiftData_SwiftUI'
I had the same problem (& tried the same cleaning/deleting steps) when I first installed Xcode 16 beta 2. It only occurred in a project that I had created using Xcode 16 beta 1. I never could figure out what was causing it. I ended up just re-creating the project fresh in beta 2 and that worked. Luckily it wasn't a very big project. I copied over most of the code files as-is from the crashing project, so I suspect Xcode was just "confused" about something in the project file.
Jul ’24