iPod App crashes on launch - objective-c

Is it normal that when i try to test my app it crashes on launch?
I explain.
I have my app that works fine in the simulator. I wanted to try to test it on my iPod Touch 4g.
I built and run from XCode, and that's what happened: the app launches fine (it shows me a black splash screen),but then suddenly it comes back to the springboard,with no reason.
If i open up the app manually,after it crashed,it works without any problems. It happens only one time,just when i build and run,and i don't know why.
How can i do to avoid this? On simulator it works with any crashes,but when i run it over my iPod,it crashes.
Program ended with exit code: 0 // on simulator

The app is likely to be failing to run on the device as xcode is trying to attach the debugger to it but doesn't have permission to do so.
Check your entitlements.plist within your project; you probably have one that has get-task-allow set to NO. This needs to be 'YES' to allow the debugger to attach. (It does need to be 'NO' for adhoc builds though - one solution is to exclude the entitlements.plist file from the debug build.)

Related

When i run my project on xcode it shows

Xcode cannot launch apps on the simulated device “iPhone 6”, as it is currently running an app on “iPhone 4s”. Only one simulated device may be used at a time
This means one of two things:
You have another project window open, and that project is debugging an app using the iPhone 4s simulator;
XCode has gotten confused and thinks you are still debugging something in the simulator, even though you are not. This happens to me pretty often, and I think it's a bug in XCode, in the way it interacts with the simulator.
For #1, go to the other project window(s) and click Stop button to stop debugging.
For #2, quit XCode and start it up again.

Xcode 5 fails to launch app with error: failed to launch '/path/to/.app' -- Busy

I am using XCode 5, with an iPhone 5s as the dev device. Every other time I run the app I get a pop that says "Could not launch [app name] \n busy". My iPhone 5s then appears to crash and the only way it will respond is if I hold the home and lock button until it resets.
The application is a single view application, the only thing I have done is added the Parse.framework from here and used
[Parse setApplicationID:appID clientKey:clientKey];
[PFAnalytics trackAppOpenedWithLaunchOptions:launchOptions];
In applicationDidFinishLaunchingWithOptions, along with some UI that isn't hooked up to anything.
I'm not sure if this has to do with Parse or possibly the App settings.
So to be clear, the behavior is:
Fresh reset > Build and Run application on iPhone 5s > application runs fine > Build and Run application on iPhone 5s > application appears to launch but screen remains black and iPhone is no longer responsive except the screen will turn off when the lock button is pressed (but not back on) > Build and Run application on iPhone 5s > XCode says "could not launch app - busy" > hard reset iPhone
When I run this on the 64-bit simulator it works fine.
Edit 1:
I have tested with multiple applications now that we know work on multiple other devices (iPhone 5, iPhone 4, iPhone 4s) and the simulators. I don't have another iPhone 5s so it is hard to compare exactly but everything crashes my 5s..
My device was completely stuck with black screen. "To fix you have to hard reboot, holding the power and home button until the phone reboots - doesn't lose any of the data you have on your phone (a concern the first time I did it)." as stated here:
http://blog.paulhadfield.net/2014/01/iphone-hangs-when-running-from-xcode.html
For iPhone7 there is a different approach:
Press and hold down the power button located on the right side of
the iPhone 7.
While holding down the power button, press and hold
down the Volume Down button on the left side of the iPhone 7.
http://www.hongkiat.com/blog/force-reset-iphone7-7plus/
You were using your phone when you ran the app. Make sure you don't use your phone after you press build and run, otherwise it will be "busy"
Which Xcode version do you use? Same issue with Xcode 5.0.1 + iPhone 5S (iOS 7.0.4). It crashed my iPhone 5S even by the simple application created by Xcode's default project template.
It seems this issue has been fixed in Xcode 5.0.2. Xcode 5.0.2 works fine for me by now.
I've got the same problem for several times. It seems that this problem always happens when iCloud or other background App is running & the App I was debug is already in running mode.
My suggestion is: Avoid any background App running when debug and Make sure the App debugging is fully killed before restart a debug.
It is obvious a bug in iOS 7 + Xcode 5.
I had the same issue and upgrading to Xcode 5.0.2 resolved it.

Crash with: another instance of this process was already running [duplicate]

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.

iOS Simulator Crash Logs

When I use the iOS simulator and the app crashes, I can't find the crash logs. I've been looking all over the internets and can't figure out how to enable them. I know I can just run on an actual device and get the crash logs that way, but the bug I'm trying to fix right now tends to cause the program to be hung in the debugger. Then there's no qlaunchsuccess packet sending and it's a huge pain, especially when I have to run the program over and over. The only advice I've been able to find says the use CrashReporterPrefs, but a search of my hard drive reveals nothing named something even close to this. I've also dug into the package contents of XCode and the files of the iOS simulator. The iOS simulator has a crash logs folder, but it is empty. Anyone know how to get this working? Thanks.
Run your App with Xcode to install the App to iOS Simulator
Launch your App on Simulator without Xcode
reproduce steps for crash
the Crash log should show up under this directory
~/Library/Logs/DiagnosticReports/
It appears if you aren't running Xcode (mine is 4.5.2) but just the simulator (mine is 6.0) that when an app crashes it does save a crash report. To view it bring up the Application/Utilities/Console and
(1) make sure it shows the log list (see top left of console to make sure not hidden)
(2) under "DIAGNOSTIC AND USAGE INFORMATION" there is a "User Diagnostic Reports" that if you open up should have your crash reports
(3) the area on the right of the console has the log
A Crash log is just an output of what the debugger already gives you. When you are running in the simulator attached to the debugger, and you hit the crash, you can view the back trace information in the debug navigator (default key binding is cmd+5)

Cannot Install into iPhone Simulator

I've got an Xcode project that I've been working on over the past few weeks.
I just made some changes to an embedded framework that I'm working on (recompiled, to be specific) now, however, I am unable to launch the application in the simulator.
The app hangs on "Attaching to [app name]," if I have a debugger on. If I don't have a debugger on, Xcode just says the app has finished running.
There is no icon installed on the device.
Here's what I've done so far:
Restarted
Reset simulator
Clean and build
Deleted derrived data
I cannot install onto a device either, but then I get an error:
Error launching remote program: No such file or directory (/Users/peter/Library/Developer/Xcode/DerivedData/x-gtwuuwmavjonyrcxjmpcletdpyjw/Build/Products/Debug-iphoneos/x.app/x).
Oddly enough, what worked was installing another app in the sim (just launched another project and ran it) and then launching the other app in the sim.
I'm not sure what the issue was, but I tried it on two computers and it was hanging on each, so it was related to the project rather than the simulator. There's an issue to think about...