App crashing in iPad simulator with no useful console info - xcode

please forgive the total newbie here - I am running an app in the simulator, and sometimes when it crashes it posts useful info in the console, other times absolutely nothing. When it posts nothing, what would be good steps to follow to start tracking down the cause of the crash?

First of all open the debugger after the crash and look at the stacktrace.
In addition to that you could enable NSZombieEnabled for the executable when those vague bad access errors show up.
Debugger with stacktrace(top left window), XCode3
Stacktrace Xcode4

I can continuously reproduce this kind of behavior with our app. It uses ARC so im pretty sure nothing gets over released, and we have zombies enabled. Xcode will say "Paused" instead of displaying a list of threads, the "Continue" button is active, but doesn't do anything, and entering bt on the (gdb) prompt says No stack.
This is driving me crazy!

Determine on what event the app is crashing. For exapmple if the app is crashing on the click of a UIButton, you can put a breakpoint on the action and step through code lines to see on which line the crash happens. Sometimes when there is no crash log on the crash of app, debugging through this method, does prove to be helpful.
I suppose this is a memory issue.

sometimes it happens to me as well.. the app crashes without any error message getting posted in the logs.. 95% of the time it is because I would be not be releasing something or would be releasing something and accessing it( which would usually create a log)... go through your code and see whether you are releasing properly and using autorelease option where needed...

Related

Xcode Debugger Doesn't Begin Session When App Runs

I'm using version 12.4 of Xcode, and when I run my app to test it, the debugger never starts a session. When I open the Debug Navigator, the message "No Debug Session" stays, and none of the normal analytics data appears.
I am running my app through Xcode onto my iPhone 12 Pro. It requires the use of the camera, and in fact the part I need the debugger for also requires the camera, so I can't use a simulator to see if that magically fixes it.
I also looked through every setting I could find that mentioned "Debug" or "Debugger", but nothing I could find changed anything.
Also, I downloaded a random tutorial app and ran that through Xcode on my iPhone, and the debugger boots up as expected.
I am completely lost and really need a GDB/LLDB tool to debug my code, so any help is greatly appreciated, as I could not find a single person or post with a similar problem to mine, and all of the Debugger tutorials and Apple Documentation are outdated and useless.
EDIT: Here is the Scheme info I have set, I have nothing in the Arguments tab. (This is a new account so I'm not allowed to embed images RIP)
Scheme Info
Scheme Options
Scheme Diagnostics
As Matt pointed out, the debugger will not point at the app target if the Executable dropdown (in Scheme Info) is "Ask On Launch". It must have the app itself selected.

How do I view console output on Apple Watch when not connected to the debugger?

So I'm trying to track down an issue that crops up when I'm NOT debugging with Xcode on the Apple watch, and I've discovered that the Apple Watch has some serious problems with console output if it wasn't launched via the debugger. Given the following code:
- (IBAction)onPrint:(id)sender
{
NSLog(#"############## Printing! ##################");
printf("************** Printf! ******************\n");
}
When launching via the debugger, it shows both lines in Xcode's console window. Great, no problems there.
If, however, I launch the watch app manually (from the watch itself), I get nothing in the console log via the devices window in Xcode, and nothing in the Console app on the mac (other than the normal "kernel[0] : prevent idle sleep list" messages the watch emits to the console from time to time).
I also tried connecting to the watch extension process using the Debug -> Attach to Process menu in Xcode, but it still won't print anything. Clear console, reload console... nothing works. I've looked all over SO for answers, and tried everything marked as an accepted answer or not, but nothing seems to work. This app is as simple as it can get: A single button that executes the code above to print to the console.
Is it just broken? Or is there some other arcane magic I must weave? I'm running Xcode 8.1 and WatchOS 3.1 on an Apple Watch 2.
It looks like this is just a limitation of WatchOS. The only way I've been able to get data back is by storing logs in a file and then fetching the file later.
Thing that can help you is called sysanalyse: you'll have to add special profile to both iPhone and Watch, and this will allow to see your app's logs in Console and via sysanalyse reports. Instructions and profiles are provided here.
If you are debugging background tasks, important to know: watchos's daemon will not terminate process what had already used it's background execution time limit if it is connected to debugger.
This is really odd because I was able to see log statements on the console. It's just now, I'm not. This is for Watch OS 6, xcode 11.2.1.

XCode: What's the fastest way to restart my app so I can debug faster?

Say I am debugging and accidentally go past the function I wanted to step into. Currently, I rerun the app again through xcode (apple+R) and have to wait for the app to load again. Is there a faster way? I looked into the stop command (apple+.) but when I load the app again from the simulator my breakpoints don't trigger.
Restarting is probably your best bet, but it sounds like you may simply have too many breakpoints set if you're mindlessly hitting "Next" by the time you get to the one you want. Try turning off some of the preceding breakpoints (particularly those in loops).
If the breakpoint is in a loop, and you really only care about it under certain conditions (why else would you skip past it?), try setting it up as a conditional breakpoint that will only stop when you need it to. Check the answer to this question for more info on how to do so.
Ok so what i understand from the question is this : you have some breakpoints into a function...you run the app from xcode ..it didn't go into that function...then you went to simulator and run it from there and the breakpoints didn't trigger.
If that what you ment by the question ..your problem is that when you run the app from the icon in the simulator that doesn't run in debug mode it runs in release mode-ish (with some minor differences) .The debug mode only works when it's directly started from xcode (so of course your breakpoints didn't trigger).
As for the loading speed..you can't do anything about that it loads as fast as it possibly can. I personally only build and run on the actual device ..and from my experience it takes 2~4 s from the time i hit run till the app loads completely. That being said i noticed that if you have a splash screen (Default.png) it takes 1~2 s more to load so what i do is just remove the Default.png from the project , delete the app from device, restart the device, restart xcode and the screen wont be loaded every time . It may not seem like much ..per build but on the course of a few weeks of development it ads up to minutes. Also..don't forget to add the Default.png when you release it ...i forgot once and app got rejected :)

Couldn't register "Application" with the bootstrap server [duplicate]

I keep getting this error when launching my app on the iOS Simulator:
Couldn't register com.mycompany.MyApp with the bootstrap server. Error: unknown error code.
This generally means that another instance of this process was already running or is hung in the debugger.
I've read other reports of this error and it seems there is no obvious fix for it (restarting the iOS Simulator, restarting Xcode etc..)
At this point here's a list of things I've tried:
Restarting the Simulator
Restarting Xcode
Rebooting my machine
Deleting my app's Derived Data, and Cleaning
Deleting the iOS Simulator App Support directory
Reverting to a 2 weeks old version of the app (which was working 2 weeks ago)
Deleting the application in the Simulator (by clicking-holding on it and hitting the X button)
Upgrading Xcode form 4.1 to 4.2, and running the app both in iOS Simulator 4.3 and 5.0
Nothing worked, I still get the same bootstrap error.. Any (and at this point I really do mean ANY) suggestion would be appreciated.
Edit: Just wanted to add that the app runs fine on a device. I only get this error on the simulator...
As the GDB said:
This generally means that another instance of this process was already running or is hung in the debugger
So find out it and kill it. ;)
I restarted the mac, and it run successfully.
Tip: Well, this may be not work sometimes, so I strongly suggest that you press cmd+. to make sure that you do have stopped the simulator (or device). I find that in most cases the simulator (or device) will not stop exactly when it crashes. I rarely met this issue again with pressing the cmd+. every time it crashes or even just normal exit. Hope this will be helpful. :)
I just closed my xcode & restart my device(ipad2) and it works for me :)
You can try this :: Couldn't register with the bootstrap Server
Another solution, go to clear the memory of the iphone simulator
Simulator > recovery content and setting
then run the program again.
i just change the identifier and the app can work again.
I had to change my bundle identifier finally
No matter you reboot all devices and cleanup all , it gets stuck hard in the debugger..
don't know how to clear it..
As I experienced, device (or simulator) restart does solve the issue,
BUT it would be better not to couse it.
Also my experience is that:
You can find the place of crash by cousing it. In such time developers usually press "STOP the running scheme" this could cause zombie process stuck in device.
BUT
if you press "COUNTINUE program execution", debugger will terminate the process, it will not become a zombie.
I had this error too and I noticed that it works for me if you close the simulator and stop the program and then change your company name.
I don't know why but it works for me.
I opened Activity Monitor and searched for my app name, and found another instance of it listed. I used Activity Monitor to quit that instance, and the problem went away for me.

ios Zombie detection

I'm having (in my opinion) a very difficult problem in my code. It crashes randomly at different places in the code. The project is a ARC project.
So my program crashes occaisonally with this messages:
malloc: *** error for object 0xd2dd8b0: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
I already set a breakpoint for malloc_error_break but I don't get any information out of it. When the code crashes ,XCode shows me the place in the code where it happens. But as I already said the crashes are randomly and do not occur always. But it seems as if the crashes are concentrated at on particular line in the code.
Now, I wanted to debug it using the instruments that come with xcode. After a bit of googling i found the following stuff on stackoverflow: How do I set up NSZombieEnabled in Xcode 4? and Xcode malloc error.
So the first link describes how to start zombie detection out of xcode itself by clicking the run button in xcode and choose "Profile". The problem I have is, that I cannot find "Zombies" when choosing the template for the trace document in my version of xcode (4.2). But if I start Instruments outside xcode (e.g. from finder) I can choose zombies.
Okay, here is what I did:
1) Start Instruments from finder and choose Profile "Zombies".
2) Start iphone app from xcode in the iphone simulator (normal run (not profile or debug)).
3) In Instruments "Choose Target"->"Attach to process"->"iPhone Simulator (57529)".
4) Instruments begins to recod something (I cannot figure out what it does).
5) Start playing around with the app until it crashes.
Eventually the app crashes and here is a screenshot of instruments after crashing the app:
My questions:
1) Is Zombies adequate for my problem or should I use another analyizes tool?
2) What tells me instruments in it's output after crashing?
Judging by your description of the problem, your crash is caused by something besides accessing a zombie object. If your app accesses a deallocated (zombie) object, Instruments shows a message like the following when using the Zombies template:

Resources