Marcel Marcel - 10 months ago 36
Swift Question

App won't reopen after closing

I'm developing an iOS app.

I have placed it in a workspace with other targets (frameworks) that I use in the app. I can run the app fine, but once double tap the home button and I close it completely, I can't run it again.
I tap on the icon, and sometimes it launches the app then quits immediately, or sometimes it simply doesn't open it.

Is there a way to fix it or to find what is causing this problem?

PD: the reason why I'm doing this is to test wether reopening the app from a local notification loads the correct data for the notification that has been opened. Trying to open by tapping on the notification doesn't work either.

Neither the debugger or the console are printing anything out.

Answer Source

This happens when you use frameworks in your project that were not customized to work properly in the simulator. Basically, the iOS simulator uses i383 (for 32-bit) and x86_64 architectures, rather than the arm and arm64 architectures that the real devices use. For some reason, when you create a framework, Xcode doesn't set it up to retain the compiled i386/x86_64 architecture code after the app is quit. It will, however, retain the compiled arm/arm64 code, so you can be sure that the app will function normally on real devices.

I personally get around this issue by using real devices when I need to test features that rely on quitting and relaunching, but there are ways to write custom build schemes on your framework to fully support the simulator. I'm not going to put a link here, though, because the specific workarounds are very diverse and I myself have not tested any of them.