Why does my app work in the simulator but get stuck on the splash screen when I run it on my iPhone? - ios

My app runs fine on the simulator. However, when I run it on my iPhone, it gets as far as displaying the splash screen and then just stays there. It's an iPhone 3GS and the software version is 5.0.1. That's what happens when Debugger = None. When Debugger = GDB, I get an error message, 'Thread 1: Program received signal: "SIGABRT"', which I have learned can mean almost anything. I'm running Xcode 4.2.1.
I'm coming off a long hard night of battling with this error message, which appeared seemingly out of nowhere in a stable mature app. I tried to roll back with time machine, I deleted the Derived data for my project in Organizer a few times and did some of the other stuff recommended in this thread.
XCode 4 hangs at "Attaching to (app name)"
It got ugly. For a while, I couldn't even reboot my machine. Eventually, I was able to relaunch finder and suddenly the Simulator was working again. Two more pieces of information, I used to have to click allow in two dialog boxes when running on my phone but now it's only one (the one about code signing, I forget what the other one was about). Second, I find all the build architecture target stuff confusing but I set all my Base SDKs to be latest iOS. Lastly, I tried Product --> Clean and then Build but that didn't fix it. As you may have gathered, I'm getting my butt kicked. Any help would be much appreciated.
Dessie

Many times I have experienced Xcode going "crazy" with a physical device connected. At times I saw the behavior you describes; other the app simply refused to start;
In all of those cases, I could fixed it in either of two ways:
disconnect the iphone and connect it again;
reboot the device.

This is a very common problem that is easily fixable.
1) remove the app from the device
2) reboot the device
3) close Xcode and you must restart, logging out will not work

Related

XCode 6.3.1 - lost connection to attached device frequently

When running my App, I'll get this occur 3 out of 4 attempts to run the app from xcode. Hitting enter & CMD-R will sometimes generate the error again, and sometimes (rarely) actually run & debug the code. This happens with both an iPhone 6 device (8.3) and a iPhone 5 device (8.2).
While it's not a show stopper, its adding to the development cycle time. Anyone out there suffering the same issue, or anyone have a solution?
I've had this happen both with and without a watch extension, but it is more pronounced when working on an App with a watch extension.
While Watch connections can be inconsistent, it seems that keeping the Watch on the charger while debugging is a noticeable improvement. That's been my experience along with others who have comment in the Apple Developer Forums.
So here's my ritual on a "quick" turnaround for build & runs:
Open your app on the Watch
Press and hold the button below the crown until the Power Off options appear
Release the button and press and hold again. This will terminate the running app.
Build & Run from Xcode
On the Debug Navigator it will hang 9/10 times at the "Waiting to Attach" screen
Help Xcode a little bit by tapping on your app icon from your Watch home screen to open it, Xcode will promptly attach.
Your new build is now running.
I really hope they fix this in the next Xcode update but this is how it's currently working for me.

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

Running app crashes iPhone5S and forces hard reset with the error "failed to get task for process" on the second launch only

I have been at this for hours and am about to start flipping tables. This problem cropped up out of nowhere after working on this app successfully for about a month. No changes to build settings or build schemes or anything that I can think of.
If I build and run the app on an iPhone 4 I have no problems at all. If I build and run the app on an iPhone5S it will:
On the first attempt: Build successfully, appear to install the app on the device and launch it, but then fail with "error: failed to launch '.../MyApp.app' -- NotFound".
On the second attempt: Build, run, have a happy little debug session and everything is perfectly fine and dandy.
On the third attempt: Build successfully, begin to launch the app, and then will fail with "error: failed to launch '.../MyApp.app' -- Failed to get task for process -1". The phone will then become unresponsive, and the only way to bring it back is a hard reset.
Once or twice throughout the past few weeks I've had this problem happen, but after resetting everything was fine. Turning on or off building for arm64 doesn't seem to make a difference, and I can't think of anything else that would be different between the two devices.
Even a hint would be appreciated.
UPDATE: I changed the build scheme to "Wait for app to be launched manually", and by launching it myself after it's been built it seems to avoid the crashing. Obviously this doesn't fix whatever the underlying problem is, but at least I can function now.
Looks like this is a known bug, and it's resolved in Xcode 5.0.2.
I'm experiencing this very same issue but the workaround I've found is to disconnect and reconnect the phone before running the app. Using this workaround, I haven't experienced the error as frequently as otherwise, but it's still a rather tedious process...
This problem is known back to first Xcode 5 Previews. It helps to disconnect and connect the phone again. MY worst experience was Preview 4 with iPad. It till happens occasionally, but very rare compared to before.

ios Simulator Could Not Find The Application To Simulate

I'm having trouble with the iOS simulator. I'm currently on 10.7 and was using the simulator to test my website. During the testing, I switched the iOS version via the tool bar, and the application froze and quit. Upon restarting, I get the following error message, with a finder window, inviting me to choose an application:
"ios Simulator Could Not Find The Application To Simulate"
Here's what I've tried to fix the issue:
1: Attempt to identify the application it needs, but the only thing i could see to open was a printer app and the ios simulator app, which just results in a "only one iOS simulator can run at a time" error message.
2: Restart the Mac.
3: Download the new Xcode tools from the app store.
4: Restart again.
None of this has helped, and I'm really stuck without it at the moment. If anyone knows how to resolve the problem, I would be grateful to hear any suggestions. Thanks.
Give this a shot.
Open up a new shell, and shoot of this command: sudo <Xcode>/Library/uninstall-devtools --mode=all (assuming thats the location of the instal).
Then run the Xcode installer you got from the app store.
This removes all the plist files that were also installed with xcode, which aren't removed when you simply reinstall. This is as close as you can come to a complete xcode refresh without reinstalling your OS.
Here's an alternative solution that worked for me... the answer selected here did not. I created a blank, "hello world" project and simply ran it. When you run the app, it sends the app to the simulator and voila! iOS Simulator has an app to simulate. From that point forward, you should be able to open the iOS Simulator without a problem.
After a while longer trying various things, it seems like I may have fixed it.
When asking for an application to open, I opened Xcode, and (weirdly) that opened up and left the testing shell visible, with the tool bar intact. I then selected the current version from the device options and hit the home button, and suddenly everything appeared.
Weird thing to have suddenly happened, but there you go.
I still can't test in iOS 3, so that's a bit of a problem, but not a disaster either!

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