XCode & Instruments, how to clear the list of processes - ios

I'm debugging an iPad app and I'm getting a GIGANTIC list of processes to attach to when selecting the "choose target" drop down in Instruments.
It's literally showing every single process that I have run and terminated when I start and stop my app that I'm debugging. They are listed under the Attach To Process->System section, that's where my IOS apps to debug always show up, but they never get removed, so I have to dig through hundreds of entries.
I've tried restarting xcode, instruments and IOS simulator... Is there any way to clear this without restarting my mac? I'd hate to have to do that every time.

Everytime you exit your app in the iOS simulator, it creates what is called a "Zombie Process". To this date, the only way you can clear these processes is by rebooting your mac.
Also, when you want to choose a target for your Instruments application, the process you will want to select will most likely be the highest-numbered process for the app you are currently testing.
Here is a stackoverflow reference regarding the zombie processes left behind by XCode: Xcode leaving zombie processes after running iOS tests/simulator

Related

Xcode 12 very slow to launch simulator

Someone could help me ?
I have a problem with Xcode 12.4, the application takes more than 5 minutes to launch the app and stay blocked building the app.
It's not a problem with my application because i have tried with the new app and the problem still be the same.
TL;DR
Run once and wait for the Simulator home screen to load. After loaded, re-run the app from Xcode. 🤷‍♂️
Explanation
I am not sure if this will actually fix the issue, but usually, I fully open the Simulator.app for that device and wait for the Home screen to load before running the app. I think Springboard (Xcode) waits to get a handshake response when the device has fully launched and then attaches the process. This handshake was a bottleneck for me.
Other potential causes
Disable Springboard injection apps like Sherlock.app.
Reduce the number of simulators open at a given time to increase available RAM.
Reduce the number of open apps so that Xcode gets more CPU time to run.
Disable Debug executable setting (or other runtime settings) in Edit Scheme in Xcode to check if the Xcode debugger is faulty (workaround).
Try a newer Mac (2017 or later, but ideally an M1) as they have more RAM and are faster.
Reduce App Bundle size - smaller Asset Catalogs, Preview Content folders, fewer third-party libraries, and no duplicate source files (including the iCloud Desktop/Document Sync zombie files bug).
Disable iCloud Desktop and Documents Folder syncing. Or at least wait till the whole laptop has been synced. The bird daemons et al. are quite intensive.

Device gets restarted when trying to run App

I have a iPhone 5 device that i use to test the app i'm trying to run. It has enough storage and runs other apps as expected.
I'm trying to run my app through xCode with this device but before it will start the app it restarts the iPhone and is not able to enter the app.
I think it is a memory issue that is causing the device to restart but i'm not sure where to look as i have tried both Instruments on the Mac as well as checking the log for the device, but because the app restarts every time on start up it does not record the data.
Is there any other app or another method i could use to see if there are memory leaks.
Try to view your iOS Device Logs from your Mac:
1- Connect the iPhone or iPad you want to view logs for to a Mac by using a USB connection, be sure to unlock the iOS device as well
2- Open the “Console” app on Mac OS, found in the /Applications/Utilities/ directory
3- From the Console app sidebar, look under the ‘Devices’ section and select the iPhone or iPad that is connected to the Mac
4- Console Log data will begin showing up immediately for the connected iOS device
And then you can analyze what cause this issue
I've recently come across this error again with xCode. After taking some time investigating and debugging using instruments, it showed there were a few memory leaks taking place during the start of the app.
In our codebase there were a few places where there were objects that were not assigned weak/ unowned, causing the memory leaks for those objects being used on start up.
After assigning weak or unowned to those objects, it solved the memory leak issues I was experiencing in the app.
For reference I used this article to understand the problem better:
https://medium.com/flawless-app-stories/all-about-memory-leaks-in-ios-cdd450d0cc34
Medium Article on the differences and how to use Weak or Unowned on a object:
https://medium.com/hackernoon/swift-weak-vs-unowned-by-examples-ffcc7c25ecc8#:~:text=The%20main%20difference%20between%20weak,will%20crash%20the%20whole%20program.

My WatchOS2 app stuck on launch with Spinner

I built a demo app on WatchOS 2.0.1, on every launch it was getting stuck with App name on Top Left corner and spinner in middle of screen on iWatch (38mm). Watch is brand new and have only native apps installed till now so there should not be any issue with memory.
I tried many times to open the app but it was repeatedly closing automatically after showing Spinner for sometime. After lots of trial my Apps screen got visible and then after on every launch it worked fine without sticking on launch. I tried to double check by Force quit my app using Power button but it worked fine then after.
Then I uninstalled the app from watch and reinstalled it and same thing happened again. It started sticking. Do anyone have Idea on this? Please help on this part.
WatchOS Version : 2.0.1
Your app is crashing, as evidenced by it "automatically closing."
You should be able to track down the reason for the crash by examining the crash report (which can be found in the Xcode Window -> Devices pane). Alternately, you should be able to interactively debug this by running the app within Xcode.
As for it eventually no longer crashing until you deleted and reinstalled the app, the app reached a state where the reason for the crash no longer occurred. This probably is related to needing to handle some error pertaining to a path or file which it is finally able to create or access. Deleting the app recreated the condition where it repeatedly crashed again.

iOS: Simulating user quitting app

I just added persistent data into my app and wanted to test it with my iPhone. When I quit my app (double tap home and swipe up), I'm unable to open it again (the icon freezes). When I try the same thing on the iOS simulator in Xcode, it crashes too. I get a SIGTERM error coming from my AppDelegate. Is this what is supposed to happen when the user quits while testing, or is this an issue with my data? Is there any way to simulate the user quitting and restarting the app to make sure my data is still there?
Thanks
This is not what is supposed to happen when the user quits while the Xcode debugger is attached (at least not anymore — this question is a couple years old after all).
If you force quit an app while running from Xcode (whether simulator or on a physical device) it just stops the debugger and you should be able to relaunch it without issue. The Xcode debugger will not be attached when you launch like that, but from Xcode you can attach the debugger to an existing process (Debug > Attach to Process).
Note, if run in Xcode and then you quit the simulator application on your Mac (or close the simulator's window) then you will get a SIGTERM error in main.swift. But this is not the same as a user terminating your app, nor is it comparable to a user turning off their device.
From what you're describing it sounds like there is a bug in your code that is causing it to freeze when launching when the debugger is detached or when it's relaunching after termination.
To simulate the user quitting and restarting you should be able to terminate the app from your device/simulator, and then either run it again from Xcode or launch it from the device/simulator and attach to the process from Xcode.
In some cases it may be helpful to put in some debugging code that pops up an alert / update some label at runtime to indicate the data persisted properly after the app re-launched so that you don't always have to have Xcode attached to diagnose problems in your app.
This is the correct behavior if you are running the app from Xcode. However, once you've uploaded/run the app once, you can test closing and reopening it. Simply stop the run in Xcode, go to your phone or simulator, and click on the app icon to open it. Unfortunately, you won't have a debugger log at that point, but you can see if your data persists.

Xcode Instruments not profiling anything

I have just started out learning how to use Instruments with Xcode. Straight out of the gate, for some reason it's not profiling anything when using the Time Profiler.
I have cleaned my project, re-built, most of the obvious things, but I'm not having any luck still yet.
It runs the app, and the timer runs, but nothing happens beyond that. No stacks show up or any data of any kind. Just stays blank.
could you try this?
Start debugging your app with xcode in iOS simulator
Open instruments, then select iOS Simulator/CPU category and choose 'Time Profiler'
Change the Target combobox, All Process/Attach to Process
Look for your app in the displayed list and start record.
This image is an example, I'm attaching time profiler to my Calculator app:
I hope this help you.

Resources