xcode run app and crash without error(only lldb). Why? [duplicate] - ios

I've been struggling with an weird issue for some time now. When running my app with the iOS Simulator initially closed it launches correctly. But if I then run it again without closing the simulator it crashes and just prints (lldb) in the error log. If I then run it again (without closing the simulator) it launches correctly. And if I do the same again it crashes. So it seems to be every second time. It works when using a iOS device and I have a college with the exact same project who doesn't experience this problem in the iOS Simulator. What I've tried is cleaning, reset contents and settings, manually removing the app, restarting my computer and reinstalling Xcode.

There's an issue with OS X 10.8.4 that causes random simulator crashes.
https://devforums.apple.com/message/817179#817179
A couple of workarounds have been suggested, including switching to GDB. See here:
We have found the issue. It is a process killing race condition in
"debugserver" when it is killing the application it is debugging which
causes this problem to occur.
The work around that should work for
all folks is to kill the app first, wait for it to go away, then hit
CMD+R. The quick turn around of just pressing CMD+R is now showing
this thread race condition more often in 10.8.4.

Apple resolved this issue in June 13th, 2013 build:

Yes, I meet it too. In Product -> edit scheme change the debugger from lldb to gdb. Can simply solve it. Hope Apple can fix it asap.

Related

Xcode 10 gets stops automatically after running when breakpoint is enabled

In Xcode when I run my project it gets stop automatically soon after started running. This is happening when I keep a breakpoint for some code. The weird thing is that, it is happening for a some particular class only. If I enable a breakpoint in other classes then it is running and working fine. I am not able to run Xcode and debug with the issues.
I tried to fix this issue by clearing all the breakpoints and quit the Xcode and run it again. But as soon as I enable breakpoint in that particular class Xcode again got stopped.
I am totally blank in figuring out the problem for this issue. If any one has come across with this issue kindly share your experience to resolve this. Currently I'm using Xcode 10.2. Thanks in advance..
For certain code, this happens. This is a known issue and I had submitted a bug report. For the time being, use print statements and add breakpoints before and after the issue code path. The problem is with the lldb rpc server crashing, which exits the debug mode. You can find it in the issue crash log under ~/Library/Log/DiagnosticReports folder.

Xcode6 can't run any app in simulator ( Domain = NSPOSIXErrorDomain, Code = 3 )

No app can run in my simulator, although building is good.
Error messsage is below:
Unable to run app in Simulator
An error was encountered while running (Domain = NSPOSIXErrorDomain, Code = 3)
In my case, I tried to run the app on a iPhone 6 simulator when I got this error. Quitted the simulator only and re-ran the app on iPhone 5s (8.1) - it worked fine.
After a while I changed the target back to iPhone 6 (without quitting it), and ran the app against it - no error shown.
As mentioned in the Xcode 6.1 Release Notes and in my sticky post in the Apple Developer Forums for the iOS Simulator, this is a known bug in iOS.
Upon installation of an app, SpringBoard will SIGKILL that app's
process in order to force a relaunch of the app with the new
executable. The problem is that there is a race condition whereby
SpringBoard may accidentally SIGKILL a new process that we just
launched rather than the old process. Which of the various error
messages you get depends on exactly when in the launch process the
SIGKILL was delivered. Normally, this shouldn't happen, so the advise
is to just try again (sorry =/). If you find that this happes to you
all the time or more frequently than you can tollerate, we are
incredibly sorry. We are aware that systems with slower disk I/O will
see this happen more frequently than faster systems, so if you are
using an NFS home directory, you may want to create a local directory
for your simulator data and setup a simlink to it from
~/Library/Developer/CoreSimulator
By Quitting the Simulator and Run the application worked for me.
For me , just Reset Content and setting in your simulator
Restart Mac can solve the problem for me.
This error is less severe than "Domain = DTiPhoneSimulatorErrorDomain, Code = 2" error that I had when I switched to Xcode 6.
For this one, I just reset and cleared contents on my Simulator...quit. Rebuilt and ran my app...and it works.
Every time this has happened to me (as of this writing, still happening on Xcode 6.1) I do not need to restart my mac to fix it. Instead I only had to restart the simulator. I exit the simulator by right-clicking on its icon in the tray and selecting the option to Quit. The I re-run my app and the simulator starts from scratch and runs my app with no error. Much quicker than re-starting the mac.
Well, I had the same error popping up, but since I force quitted the simulator then ran the project again I got it fixed and running fine. Hope that helps you :)
If this error occurs with ionic framework, make sure you have an app id given in your config.xml
This is a generic error which says that it is unable to launch the app. The real error is in the log file. Go to the Simulator menu, Debug / Open System Log. Then press Reveal button to open the folder with actual Simulator logs. In my case it was CoreSimulator.log.
Here you will find the real error. My error was Could not register service com.apple.gputools.agent.producer.sim .
After a lot to struggle and trying all suggestions for half a day, I just went to simulator menu and chose File / GPU Selection / Use External GPU when available. That's it.
please download new xcode_6 beta 4. your project will work in simulator. As i have tested as well.
Sometimes the beta version of XCode is wrongly configured to use the command line tools from the previous xcode version.
This solution should fix the issue for you : https://stackoverflow.com/a/25415781/512504

Xcode does not run the app on simulator. (App exited unexpectedly)

I'm developing for iPad (iOS 7), using Xcode 5.0.2.
Yesterday morning I was playing around with the app (my first app) and every time I ran it, it was displayed in the emulator perfectly. But after some 5/6 runs Xcode just stopped launching my app in the simulator. I started to receive this message:
MagazineManager exited unexpectedly - lost connection
Image:
I've been researching since yesterday morning for a solution with no luck. I even uninstalled and reinstalled Xcode, cleared the cache, delete folders... all that drama thinking it could be some sort of cache problem.
Then, going online I've tried lots of "solutions", none worked.
I've tried all listed here: Xcode suddenly stopped running project on hardware: "Could not launch xxx.app: .. No such file.."
and here:https://discussions.apple.com/message/23431537#23431537
and in more places.
After all my "try this, try that" I'm stuck with the same problem. I can only see a black screen at the simulator (image below) and that message at Xcode!
In my extensive research I've read that people are still able to debug using their iPad's. The problem is that I got the new iPad air, that's only getting here dec, 20th!! So I don't have a place to test my app[s].
Thanks!
UPDATE
Just got this message in the debugger console:
013-12-09 20:23:25.902 sim[607:303] /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/usr/bin/sim: Did not find an executable file at the path: '/Users//Library/Developer/Xcode/DerivedData/MagMan-bvhhiijesvrvuteunbmpsxcqgsst/Build/Products/Debug-iphonesimulator/MagMan.app'
My problem was the debugger. Actually, it still is.
The way I solved, and have been doing for every new project, was to disable the debugger and then run the project. That way I'm able to use the app on the simulator but without the debugging functionality.
I don't know what the problem is, what is causing this debugger issue in my case, but for now that's the best I could come up with. Thanks to the friends that replied to my question and helped my research I was able to test it and disable it.
This is how I disabled the debugger:
Project > Edit scheme
Set Debugger to None
If anyone knows a solution for this, feel free to answer this question and I'll make sure to update the selected answer accordingly.
Again, thanks for all your time and patience, specially #Popeye and #HotLicks that spent a lot of their time trying to help me.
Sometimes the simulator can be a bit flaky and just needs resetting. In the navigation bar at the top of the screen when the simulator is visible try:
iOS Simulator --> Reset Content and Settings...
This should reset all the settings and remove the content so all data, images, apps etc will be removed, its like it has never run before.
UPDATE
The answer on XCode5 can't install app on iOS simulator indicates the following
I found a "Fix" for this. After trying everything and getting the same error on "My App", I opened and tried to run "My App 2". "My App 2" ran fine, so I went back to "My App", tried again and this time everything worked fine. Crazy
If that doesn't work leave a comment and I will have another look.
Delete the app and restart your iPad it will work

Xcode 4.6 hangs on "Attaching to..." when using LLDB debugger

As the title says, I'm having issues using LLDB. I've looked into this thread Xcode 4 hangs on attaching to (App name) when debugger is set to LLDB and followed the instructions given because I'm having exactly the same issue, and managed to debug by using GDB - it works flawlessly. Anyway, i'm working in a team and I'm the only one who's having this issue, so it's a bit annoying to switch back and forward from GDB to LLDB every time i commit changes so the workaround doesn't get synchronized in the remote repository.
I've checked the compiler, and it's set to LLVM 4.2. In fact, the app compiles perfectly and gets installed in the simulator (i can execute it once I kill and restart Xcode). I would try to reinstall Xcode, but it's a mess since it's a big-sized package and I have a limit on my internet usage, it would take a long while. Does anyone know what's happening here? Is it possible that LLGB is bundled outside XCode, even if I failed to locate it on the system?
Any insight would be appreciated. I can keep the workaround going, it's just that it's a bit annoying given my personal circumstances :-)
EDIT: More details about what I mean by 'hung'. I start with Xcode open, and simulator closed (it doesn't even appear on the Dock). I click 'Run', the simulator is launched successfully, and the application shows the Splash Screen. Then xcode shows the message: "Attaching to ". And now it's hung. You can close the simulator, and xcode is still attaching. Both the Run and Stop buttons stop working. You can try to exit the application by right-clicking on the dock, you get an alert message, and from this point you can't even type code: XCode is fully hung. The only choice here is to kill XCode by using Cmd+Alt+Esc.
This sounds like it could be the problem some folks were seeing in Why does the LLDB Debugger constantly fail to attach? where they'd modified their /etc/hosts file so when Xcode tried to connect to debugserver via "localhost", the connection was never set up.
When Xcode hangs, try switching to Simulator by clicking on its Dock icon. Don't use Cmd+Tab.
Upgrading to XCode 4.6.2 fixed this issue for me

Error when testing on iOS simulator: Couldn't register with the bootstrap server

I was testing my app on the simulator when it crashed on clicking a button of a UIAlertView. I stopped debugging there, made some changes to the code and built the app again. Now when I run the application, I get this error in the console
Couldn't register com.myApp.debug 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.Program received signal: “SIGABRT”.
I tried removing the app from the simulator, doing a clean build but I still get this error when I try to run the app.
What should I do to be able to run the app on my simulator again?
status: this has been seen as recently as Mac OS 10.8 and Xcode 4.4.
tl;dr: This can occur in two contexts: when running on the device and when running on the simulator. When running on the device, disconnecting and reconnecting the device seems to fix things.
Mike Ash suggested
launchctl list|grep UIKitApplication|awk '{print $3}'|xargs launchctl remove
This doesn't work all the time. In fact, it's never worked for me but it clearly works in some cases. Just don't know which cases. So it's worth trying.
Otherwise, the only known way to fix this is to restart the user launchd. Rebooting will do that but there is a less drastic/faster way. You'll need to create another admin user, but you only have to do that once. When things wedge, log out as yourself, log in as that user, and kill the launchd that belongs to your main user, e.g.,
sudo kill -9 `ps aux | egrep 'user_id .*[0-9] /sbin/launchd' | awk '{print $2}'`
substituting your main user name for user_id. Logging in again as your normal user gets you back to a sane state. Kinda painful, but less so than a full reboot.
details:
This has started happening more often with Lion/Xcode 4.2. (Personally, I never saw it before that combination.)
The bug seems to be in launchd, which inherits the app process as a child when the debugger stops debugging it without killing it. This is usually signaled by the app becoming a zombie, having a process status of Z in ps.
The core issue appears to be in the bootstrap name server which is implemented in launchd. This (to the extent I understand it) maps app ids to mach ports. When the bug is triggered, the app dies but doesn't get cleaned out of the bootstrap server's name server map and as result, the bootstrap server refuses to allow another instance of the app to be registered under the same name.
It was hoped (see the comments) that forcing launchd to wait() for the zombie would fix things but it doesn't. It's not the zombie status that's the core problem (which is why some zombies are benign) but the bootstrap name server and there's no known way to clear this short of killing launchd.
It looks like the bug is triggered by something bad between Xcode, gdb, and the user launchd. I just repeated the wedge by running an app in the iphone simulator, having it stopped within gdb, and then doing a build and run to the ipad simulator. It seems to be sensitive to switching simulators (iOS 4.3/iOS 5, iPad/iPhone). It doesn't happen all the time but fairly frequently when I'm switching simulators a lot.
Killing launchd while you're logged in will screw up your session. Logging out and logging back in doesn't kill the user launchd; OS X keeps the existing process around. A reboot will fix things, but that's painful. The instructions above are faster.
I've submitted a bug to Apple, FWIW. rdar://10330930
Try quitting and restarting the simulator? If "worse comes to worst" you can always try restarting: in my experience this should fix it.
I find I have started having this issue with Lion + Xcode 4.2. I have also experienced the issue in Xcode 4.3.
I have tried all the suggestions but none of them have worked other than a full reboot.
Here is how you determine if you require a reboot quickly.
List out all your Zombie processes:
ps -el | grep 'Z'
If you see your app listed as a Zombie process you will need to reboot your machine. The error message states "This generally means that another instance of this process was already running or is hung in the debugger". Well, Xcode is detecting this Zombie process which you can't kill. The only way you can then fix it is with a system reboot. :(
EDIT, 20120823: I have some better knowledge of Zombie processes so I wanted to update this answer. A Zombie process is created when a parent process does not call wait() (wait for process to change state) on a terminating child process. You can't run 'kill' directly on a Zombie process but if you kill the parent process, the zombie child process will be 'reaped' and removed from the process table.
I haven't seen this issue in a long while so haven't inspected to see what the parent process is in this scenario. The alternative to killing the parent process is to reboot your system. :)
I just had this happen to me: I was getting the error only on my device and the simulator was working fine. I ended up having to reset my device and the error went away.
I'm having this problem very often recently. What would prevent this from occurring? Logging out and in fixes the problem but.. it's annoying to do so every so often.
EDIT:
I just found the cause. I had a bug in ApplicationWillTerminate method. So when i click stop button on Xcode window, app couldn't properly terminate and started to hang.
check Activity Monitor to see if your app is on the list. force quit if possible.
If you find your problem is due to zombie processes: ps -el | grep 'Z'
(as in the earlier comment https://stackoverflow.com/a/8104400/464289) and just want to fix the problem immediately, you can do so without rebooting or killing anything. Just rename your project target executable:
Click on the project on the left-hand pane
Select Build Settings in the middle pane
Under 'Packaging' change 'Product Name' from $(TARGET_NAME) to $(TARGET_NAME).1
Easy!
Well, no answers but at least one more test to make. Open Terminal and run this command: "ps-Ael | grep Z". If you get two entries, one "(clang)" and the other your app or company name, you're hosed - reboot.
If you are a developer, enter a short bug and tell Apple how absolutely annoying having to reboot is, and mention they can dup this bug to "rdar://10401934" which I just entered.
David
Resetting the iOS Simulator fixed the error for me. Although this will remove all of the Apps you have in Simulator, it fixes the problem without having to restart the machine.
You can reset your iOS Simulator by doing the following:
1) Go to the "iOS Simulator" menu, next to the Apple () logo on the far left of your main screen.
2) Select "Reset Content and Settings...".
3) Read the pop message and if you agree click "Reset" otherwise, click "Don't Reset".
Close simulator
Stop the app from running in xCode.
Open Activity Monitor and search for a process running with your App NAME.
Kill this process in Activity Monitor
Rebuild your project and you should be all set
I had a recursive setter that blew through the stack and killed my app in such a way that I had to power boot my iPad. It was provable with a fix in the code.
I had the problem #jyap mentions with zombie processes. The only way to clear them was to reboot. However, I noticed that my friends working on the same project would get the same issue but could kill the simulator without creating a zombie process. I completely uninstalled Xcode and re-installed it, and while I still get the error, it doesn't create zombie processes, so I don't have to reboot.
Before I did that, I was using this really ugly workaround: change your app ID and run again. You end up with junk copies of the app in the simulator, but you can put off rebooting for a while.
This error happens a lot to me, almost every time I test the app in the Simulator, forcing me to restart.
Here's a workaround if you want to get some work done:
Click your project in the Project navigator
Go Target -> Info
Add a key for Application does not run in background and set to YES.
This will mean that when you press the home button in the simulator or quit the simulator, the app doesn't hang.
Don't forget to change this setting back before distribution! Put it on your release checklist :)
If this happens when testing on the iPhone. Just restart the phone. From what I have been told the phone or simulator still believes there is an instance of the app running, so when it was last run it had not terminated correctly do to either an error in your code or the phone/simulator just wanted to have a moan.
I got this error while debugging my app on an iPhone 4. Hard rebooting the iPhone solved my problem. (Powering off the iPhone hung...)
I did not have any zombie process on my mac and rebooting the mac did not solve the problem.
Maybe this bug can manifest itself on both the simulator and actual devices???
Restarted the Device, Worked! :D
Thanks Everyone for the great suggestions.
I just had this error. I tried restarting the simulator and Xcode but my project would only work again after a clean and build. No idea what caused it.
I had same problem and solved it by doing the following
Deleting the app from the device,
Disconnecting the device from Mac,
Turning the device off and back on,
Quitting and relaunching Xcode,
Quitting Instruments,
Finally, Clean and Build again.
I also did one more thing, because Xcode is configured to use iOS 5.0 and my project uses iOS 4.3
Remove all frameworks and add them again.
Alternate workaround:
Give your app a new identifier. If it's called com.foobar.myapp, call it com.foobar.myapp01
You lose all data in the app as it's actually a new app running as far as the iPhone simulator is concerned. This may or may not be more annoying than rebooting - just wanted to add it to the list.
The Cause
Running your app in the Simulator before the previously running app has completely stopped.
The Fix
Wait until you see the Stop button become active again before running again.
(I'm using Xcode 4.2.1. This problem happened very frequently when I upgraded to OS X Lion).
Fixed by rebooting my phone after deleting the app, then rebuilding it clean and running again. Works fine now.
Weird.
No rebuild or reinstall needed for my issue, and in my case the error appeared when trying to run the app on the iPhone. Simulator worked fine.
Solution: Delete app off phone, do a cold restart of phone and now all is well.
Happened a lot for me with Xcode 4.2.1 on Lion. Updated to 4.3.2 and it doesnt happen anymore. Glad they fixed it.
Mike Ash posted a solution (god bless him!) that doesn't require a reboot. Just run:
launchctl list|grep UIKitApplication|awk '{print $3}'|xargs launchctl remove
The above command lists out all launchd jobs, searches for one with
UIKitApplication in the name (which will be the job corresponding to
your app that's improperly sticking around), extracts the name, and
tells launchd to get rid of that job.
I think this is caused by force-quitting your app on the iPhone prior to pressing the stop button in Xcode. Sometimes when you press the stop button in Xcode, then it takes extra time to quit the app if it hung. But just be patient, it will eventually quit most of the time.
You may alloc variable in function or tab. It will dealloc if your function or tab is quit.
So you must declarate it member variable or global variable.
I was getting this error all the time until I stopped trusting the "Stop" button in the Run dialog box. Now that I always hit stop in the toolbar before trying to run, I have yet to encounter any zombie processes.
Oh my - I tried EVERYTHING listed above and in other posts. Re-installed Xcode, rebooted my machine, copied all the missing files into the right folders... Eventually I backed-up my iphone, wiped it and restored it, and it worked!
I think what may have been the cause from reading in and around this was disconnecting my iphone white it was running with performance tools catching leaks. Or some such thing.
Aaaah, big sigh of relief.
In most worst condition Reset content and setting of iOS Simulater, and most of the time in my case, quitting XCode along with simulator, always work works for me with XCode4.6 (that frequently get hanged)
I faced this kind of issue once in my case here's what i did
Delete the app from simulator.
Delete the derived data folder.
Perform a clean action in the project by selecting the product menu - clean
Reset the simulator.
Quit Xcode.
Try running the project now if its working fine else go to step 7
Repeat all steps from 1 to 5 and then restart your machine.
In most of the cases i got it running at step 6 extreme cases i had to restart my machine.
This error used to occur in older versions of the iOS Simulator because older instances of a job in another device that was shutting down could collide with the new instance.
iOS 6.0 and later should not experience issues like this because iOS 6.0 introduced the usage of bootstrap subsets, and iOS 7.0 introduced the usage of a dedicated bootstrap server (launchd_sim) which is completely isolated from the host's bootstrap server.

Resources