app crashing on device - iphone

the app I've installed on an iPhone 3G device periodically crashes. I'm wondering if it's the device or the code. the code works fine on the simulator.
I have other apps from the app store that do the same thing. e.g. the stackoverflow app - whenever I do a search the app crashes. I've even had the iPod app crash too.
I've restored the phone a few times and still the same thing. I'm getting ready to upload the app to the app store and was wondering if anyone had any tips to make sure that my code is not the problem. it's difficult to tell because there are no errors in the simulator or memory leaks in Instruments
thanks in advance.

You can be guaranteed that it is your code. Run it in the debugger on the device and see where it is crashing. If you are getting EXC_BAD_ACCESS use the following to help track it down
http://www.cocoadev.com/index.pl?NSZombieEnabled

It most certainly is your code that crashes.
Run in debug mode and watch the console (real debug mode, not only the debug target).
Also, you can (and should) grab the crash report from the organizer. You can also watch the device's console there.

Are you sure you are not running out of memory?
the easiest way to see if this is your problem is to implement didReceiveMemoryWarning method of your controllers and check if they are called.
In the simulator you can simulate a memory warning but I am not sure if even in simulator app will crash if memory is not released. (I believe not)
Also run your app with instruments, using allocations: Run > Run with performance tools > Allocations.
And use your app for a while and you will see. ;)

Related

App crashes on device and while using instruments only

I am encountering a strange behaviour, my app runs smoothly on simulator but crashes on device.
Also when i try to detect leaks using instruments it just crashes on both simulator and device.
I am totally stuck as i am not even able to generate any error message on console, also NSZombieEnabled is on in the settings.
I can see two possible reasons for the behavior you describe:
device is short on memory; (but you would see some processing in this case)
your app uses a newer SDK than what you have installed on your device (like using the SDK 5 twitter framework and then running your app on an SDK 4 device).
Specifically, in case 2, you would not see any log messages because the app would fail as soon as it tries to load the missing framework in memory.
In any case, inspect the device log in Xcode Organizer window to have more info about the crash. This is the only way you can understand what is happening.

How to debug ad hoc version?

I have an app, it worked well on simulator, but the ad hoc version always crashed when started on my ipod.
Is it possible to debug ad hoc version or its there any replacement solution?
Thanks
interdev
Interdev, try running the debug version on your device; from your description, it seems like there may be some difference between simulator and device, rather than the ad hoc and debug versions.
If that doesn't give you the answer, and it is actually some issue with the ad hoc version, you can always access the crash logs for the device from the Xcode Organizer (Window > Organizer). Good luck!
The suggestions from others to run on debug to find out what the problem is, is good. Beyond this, there are many reasons why apps work on the simulator but not a real device. My top three reasons are:
Case sensitivity. Mac OS 10.x is not case sensitive. iOS is. If you're referencing any files/graphics etc in your project and you have the case wrong, it will work fine on the simulator but die horribly on your device!
Read/write bundle files. On the simulator, you can edit bundle files within your code. On the device, you can't. If your code depends on you being able to do so, again it will work great on the simulator but not the device!
Memory. If there are big memory leaks everywhere your simulator will probably crash as well as your iPhone. But if you're just using lots of memory - perhaps loading in loads of image files into an NSArray - this will work just great in the simulator, but will die a horrible death on the device!
In summary, remember it's a simulator, not an emulator!
instead of building for Ad-Hoc, keep it in DEBUG mode when ran on your device, then try RUN > DEBUG - Breakpoints On

App freeze and then crashes on splash screen

I have an iPhone App published for a while, developed under the SDK3, and everything works great. Some weeks ago, when Apple released the SDK4 I made some changes to my app to support multitasking (it plays audio in the background).
In my simulator and my device (iPhone 3GS iOS4) the app runs great, there is no problem at all. But, now when I submit the update, a lot of users are contacting me because they say that the app freezes on the splash screen and after waiting about 40-60 seconds, it crashes.
By asking to the users, I have determinate that the problem is only in those devices that haves iOS4 (iPhone 3Gs and 4G).
I tested the app over and over in my simulator and my device but it never happens to me!! Some one have any idea or information about this?
I will really appreciate it. Thanks.
After search for the crashes, and try over and over, I can't reproduce the bug on
my devices. So, I decide to start reading at the Apple Developer Forums and I
found a thread where my suspicions are affirmed: this problem is caused by an internal
iOS4 bug.
"There's a bug in the App Store's code signing process. Talk to DTS: they can
help you with the workaround. Mention rdar://7909951."
"...but it should be the cause of nearly all "failed to launch in time" inside
libobjc:_mapStrHash..." (This appears in some of my app crashes)
Here is the link to the post: failed to launch in time in iOS4
There is no certain solution, but some suggest that a start is changing from arm6 to arm7 and try.
You can try changing some code in the app for producing a different binary and submit it again.
I hope it can help anyone else.
Check the crash report on itunesconnect.apple.com
iPhone 3G also supports iOS 4, except it "doesn't support multitasking" (presumably due to lack of RAM?). If you're only seeing crashes on the 3GS and 4, then that might be the issue.
Default.png is shown on launch, but it's also shown on the foreground when the OS didn't manage to get a screenshot while backgrounding, or for various other reasons (e.g. your app was launched with openURL, so the UI is likely to be different).

Does anyone experiencing freezing during iPhone app launching or closing?

App freezes, and the device freezes sometime during launching or closing. This happens especially to the app developed and installed using Xcode. Can anyone explain what's going on, if it's iOS 4 Gold Beta specific issue, or a generic task must be handled by a developer?
Use the Debugger, Console and NSLog() statements to track the progress of your application throughout its life. This will help you track the bug in your application.

NSLog outputs to console when running on iphone simulator, but not when running on device

Has anyone heard of that before? It's making me crazy.
It happens only in the main app I'm working on. Other apps do show NSLog's in the console when running on the device.
I've tried re-installing the sdk, rebooting the computer, cleaning, deleting the build folder, rebooting the phone, a million things. I know the nslog code gets run because the exact project shows them in the sim. Also, even nslog's surrounding the code that loads the initial view in appdelegate's applicationDidFinishLaunching do not display when run on the device.
The app runs fine on the device, but I get no nslog output to the console.
If anyone can help it would be so greatly appreciated!
--Steve
Are you looking in the Console application, or in the Xcode console available through the Xcode Organizer? The former is used by the simulator, the latter is used for devices.