I am developing an app to control DJI drones by using DJIs Mobile and UX SDK. I am aware, that the problem I am facing might be related to their code, but I am hoping for some pointers on where to look at or things I can try to troubleshoot the issue.
I have explained the issue with code examples and screenshots on Stackoverflow: https://stackoverflow.com/q/67320963/1065468
The remote of the drone is plugged into my iPhone and I start the app through Xcode on my phone wirelessly over the network.
While the app works as it should when started from Xcode, it does not work when I just press the app icon on the iPhone.
Checking my log output of the app on the phone in the console of my Mac, I can see, that the underlying connection to the drone is working and the app should update.
Could it be a difference in configuration when the app is started from Xcode or directly from the phone?
Looking forward to any pointers from you to help me troubleshoot this problem.
I have explained the issue with code examples and screenshots on Stackoverflow: https://stackoverflow.com/q/67320963/1065468
The remote of the drone is plugged into my iPhone and I start the app through Xcode on my phone wirelessly over the network.
While the app works as it should when started from Xcode, it does not work when I just press the app icon on the iPhone.
Checking my log output of the app on the phone in the console of my Mac, I can see, that the underlying connection to the drone is working and the app should update.
Could it be a difference in configuration when the app is started from Xcode or directly from the phone?
Looking forward to any pointers from you to help me troubleshoot this problem.
Finally, it works!
I had to re-introduce the AppDelegate with @UIApplicationDelegateAdaptor as explained with some code examples in my answer on Stackoverflow and also below.
It works, which is nice. Still trying to figure out why it works though.
If anyone has any deeper understanding of this, feel free to post here. I really would like to understand.
So, before, I had this:
And after the bugfix, the working solution:
I had to re-introduce the AppDelegate with @UIApplicationDelegateAdaptor as explained with some code examples in my answer on Stackoverflow and also below.
It works, which is nice. Still trying to figure out why it works though.
If anyone has any deeper understanding of this, feel free to post here. I really would like to understand.
So, before, I had this:
Code Block swift @main struct MyApp: App { var someClass = SomeClass() @Environment(\.scenePhase) private var scenePhase var body: some Scene { WindowGroup { ContentView() } .onChange(of: scenePhase) { (newScenePhase) in switch newScenePhase { case .active: print("active") someClass.doSomethingThatWouldNotWorkBefore() case .background: print("background") case .inactive: print("inactive") @unknown default: print("default") } } } }
And after the bugfix, the working solution:
Code Block swift import SwiftUI class AppDelegate: UIResponder, UIApplicationDelegate { var someClass = SomeClass() func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { someClass.doSomethingThatWouldNotWorkBefore() return true } } @main struct MyApp: App { @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate @Environment(\.scenePhase) private var scenePhase var body: some Scene { WindowGroup { ContentView() } .onChange(of: scenePhase) { (newScenePhase) in switch newScenePhase { case .active: print("active") case .background: print("background") case .inactive: print("inactive") @unknown default: print("default") } } } }