How can I prevent iOS Simulator from presenting the "Do you want to try to reopen its windows again?" on launch, which breaks automation? - ios-simulator

Our test automation sometimes makes the simulator crash. In these cases, we often see the dialog below throw on the simulator's next launch. This modal UI dialog breaks automation by preventing application execution until the user chooses an action.

When the iOS Simulator crashes, the application state may be saved in ~/Library/Saved Application State/com.apple.iphonesimulator.savedState. The presence of this folder or values in the data within triggers the modal dialog.
Removing this folder (rm -rf "~/Library/Saved Application State/com.apple.iphonesimulator.savedState") before restarting iOS Simulator will prevent the dialog from appearing. This has been tested with iOS Simulator shipped in Xcode 9.4.1.

Related

Xamarin Forms - iOS debug on actual device hangs on launchscreen. Workin on simulator

I have a XF app already published on the play store and now I am targetting iOS. During developpent I made sure the app was still working on iOS, using the simulator only.
On the simulator everything works as expected, the launch screen is shown then the MainPage starts. But when I debug on an actual IPhone device, the app get stuck on the Launchscreen.storyboard for about 20 sec then the app exits. I've no debug output and it seems that the AppDelegate is never hit. Breakpoints in AppDelegate.FinishedLaunching method are not hit for instance. I tried to F11 for start in debugging mode but I don't hit anything, still hanging on the launch screen. I was expecting the transition from simulator to device to be less painful.
My plist file contains the following permission requirements
...
<key>NSLocationAlwaysUsageDescription</key>
<string>We need to use your location</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>We are using your location</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>This app needs access to photos.</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>This app needs access to the photo gallery.</string>
The only difference I saw is that location permissions are not asked on the device while in the simulator it asks for it at start. But this might be related to the fact that I can't reach AppDelegate, I am not sure yet.
The iOS project was generated via Prism templates. I am using VS 16.8.0 on Windows, XF 4.8.0.1687, Prism 8.0.0.1909, Xamarin iOS SDK 14.4.1.3 and I am set to "don't link" for linkers option. The device is an Iphone 10.
Any idea how can I find out the root cause - or get some useful logs?
Thanks in advance for your help.
EDIT:
Here are the device log output during a new installation https://taits.s3-eu-west-1.amazonaws.com/devicelogs.txt. I am trying to go through them but kinda lost.

Manually saving scene NSUserActivity on iOS/iPadOS 13

I have implemented iOS/iPadOS 13 state restoration using NSUserActivity, mainly because my app supports multiple scenes.
The problem is that when I'm running the Simulator with two side-by-side scenes and force restart the app by rebuilding the activities are not saved and the UI is not properly restored on relaunch.
On the other hand if I first go back to the iPad home screen and then I force relaunch the app, the activities are properly restored.
Would this mean that a crash of my app would prevent saving these activities leading to an inconsistent UI state on relaunch?
And how could I periodically "force" saving activities (get stateRestorationActivity(for scene:) called)?
The problem is that when I'm running the Simulator with two side-by-side scenes and force restart the app by rebuilding the activities are not saved and the UI is not properly restored on relaunch.
What you're seeing when you "force restart the app by rebuilding" is the expected behavior. When you force restart like that, the app does not have a chance to save your NSUserActivities. Per Apple's state restoration tutorial:
If you want to test your app’s ability to restore its state, do not use the app switcher to kill the the app during debugging. Instead, use Xcode to kill the app, or kill the app programmatically. One technique is to suspend your app using the Home button, and then stop the debugger in Xcode. When you launch the app again using Xcode, UIKit initiates the state restoration process.
I understand that you weren't killing the app in the switcher, but any "forced" stop will disable state restoration (with a caveat). To test state restoration, instead use the technique suggested by Apple's tutorial above.
Would this mean that a crash of my app would prevent saving these activities leading to an inconsistent UI state on relaunch?
I think so. This is the caveat from earlier. While Apple says that killing the app (whether in the app switcher or from a crash or whatever) will disable state restoration, this is not necessarily true. You can see for yourself that Apple's own apps have odd state restoration inconsistencies when killed in the app switcher and re-opened (you may have to try it a few times to get inconsistent behavior). While I haven't tested this, I'd imagine that those same inconsistencies can occur from app crashes.

watchkit extension 2 iOS app crash at start in simulator

I have configured the WatchKit App to run in my project (WatchOS2).
When I try to run it into the simulator the WatchKit App start perfectly, but each times I'm trying to start the iOS app, this one crash.
The simulator's log show me that :
com.apple.CoreSimulator.SimDevice.5F243C10-E98D-4A20-8950-2742FE6CABD5.launchd_sim[13288] (UIKitApplication:com.MyCompany.MyProject[0x847][13496]): Service exited due to signal: Trace/BPT trap: 5
All of my code in the application delegate is in comment. just enough to start
If I build and use my main app target with the same simulator setting, that works nicely. it just when I build and run the watchkit extension target.
I tried to clean everything (derived data, simulator setting and contents).
I know, it is not the simulator, because with a new project, the issue is not here. it might be something set somewhere ??
but nothing works, any idea ?.
Your application aborted, likely due to a failed assertion. You should look at the crash log (in ~/Library/Logs/DiagnosticReports) for more details.

How to get Meteor real time update between browser and mobile simulator?

I created default scaffolding app in Meteor and after installing mobile platform I ran it in simulator (both Android and iOS). I also opened a browser to view the app (localhost:3000). When pressing Click Me button I do not see any updates in either of the simulator running this app.
Clicking button on browser page shows count increase on browser and this increased count is not reflected on simulator. See screenshot below.
Any idea?
Meteor 'click me' application stores the count of the clicks in the session. Your browser and the mobile simulator have different sessions. You need to store the count in the database if you want to see it in the simulator too.

iOS Simulator keeps asking for an app to simulate

I only use the iOS simulator for testing websites, not actual apps. Today I opened it up and it keeps asking me for an app for it to simulate. If I click cancel, it just quits the simulator.
I've tried deleting preference files, but I'm just not familiar enough with the simulator to know what's going on. How can I just get this back to normal, or satisfy this dialog?
I think you could try the menu
iOS Simulator -> Reset Content and Settings...
This would clean your simulator storage.
Update
According to this link, Cleaning up the iPhone simulator
move to path
/Users/<username>/Library/Application Support/iPhone Simulator/{6.0 / 6.1}
You could try to clean it manually

Resources