iPhone App Different Behaviour Archive Version Compared to XCode Debugging - iphone

I've got a frustrating problem here in that my iPhone app seems to run fine in XCode (running in the simulator or debugging it with iPhone plugged in), but archive versions act differently.
My sprites are supposed to perform movement only in a strict grid pattern and at constant speeds, but they are sort of skipping around and moving in unexpected diagonals.
I don't think it's IOS7-related because the problem doesn't manifest in the new version (7) of the simulator.
I never saw this problem in months of development and dev testing. It only seems to have started happening since I started producing and distributing archives.
App details:
Game, cocos2D
Hardware:
MacBook Air, iPhone5, IOS7

I ended up getting some help from someone on the Apple Developer Forums, but I'd like to update this posting as well, even though it's redundant.
I've been running XCode for over 2 years and I didn't realize build configurations could cause different behaviour.
By setting the Run scheme to use the Release build configuration I was able to re-create the problem on the device.
The problem still existed of course, but this posting I found suggested turning off compiler optimizations to solve a vaguely similar problem.
That did it. Somehow the calculations that occur to control sprite vectors in my application behave strangely with compiler optimizations turned on.

Related

XCode 4 project falls apart in XCode 4.2

I have a 6 month old app on the AppStore, which compiles and runs without problems using XCode 4.0.2 on Mac OS 10.6.8, and has no issues on any devices when purchased.
Recently, I wanted to roll out a new version and made some improvements that do not even involve a change in code. All looked good in the simulator, but when I tried to install my Ad-Hoc build, I ran into a problem: my devices are now running iOS 5.1.1 and it wouldn't install.
Restoring back to iOS 4 proved impossible, so I installed XCode 4.2 with iOS 5 SDK. (I'd be ok with upgrading to Lion as well but...)
The App completely fell apart when I tried to run it in the simulator, with about 50 issues here and there, and wouldn't even get past the first screen.
Although I can find my way around in the written code, I'm not a programmer, and have no clue as to how I could fix all those issues. Apart from hiring a programmer with each new iOS release, is my only option to directly release it on the AppStore and do my testing with a live product? (E.g. under a disposable App ID)
I just can't wrap my mind around as to why a product that runs perfectly fine on the actual device can not be run on the test bed.
Thanks for putting up with my rookie question, I really would appreciate your guidance.
(Screenshot of warnings: http://www.sunnyphotography.com/_temp/warnings.png )

memory-leak happens when running on physical iOS device

When testing my app, everything runs fine on the iOS simulator, but I experience memory leaks when running the same app on a physical iOS device. I am new to developing iOS apps and I know that are many potential reasons for this. I want to know why things are different between the simulator and a physical device and if there is a way to solve my memory leak issue?
I would suggest you go through the tutorial below. It will help you a lot to understand how to debug your memory problems and other issues.
My App Crashed – Now What? 1/2
My App Crashed – Now What? 2/2
hint: your problem can be solved with zombie objects; but I advise you to follow the tutorials first.
I'm surprised that you have a leak in your device and not in the simulator. How did you conclude that? Both could be leaking, but the problem is just being manifested differently on the different platforms or simply encountering the problem more quickly on the device than the simulator.
If you have a leak, I'd suggest two things:
Run your code through the static analyzer (select "Analyze" from the "Product" menu in Xcode). Newer developers tend to ignore this incredibly useful tool. I know that I finally mastered my Objective C memory management techniques only after going through the analyzer results and really understanding (and resolving) each and every issue in a really big project I had. Anyway, if you're getting any warnings there, you really should fix them, as they're often indications of memory management problems.
Run the program through the profiler. See the Finding Leaks documentation.
Yes, there is a difference (sometimes an annoying large one) between the simulator and the device. This is because the underlying hardware of each is quite different. Obviously the simulator is simulating the iOS hardware, but that doesn't make it foolproof. With certain APIs and frameworks, things may ONLY work on the hardware, and sometimes bugs will occur on the hardware that didn't occur on the simulator. Just think of it as the "adventure" of iOS development.
As for resources, I'd take a look at #Arab_Geek's links, and also Apple's Tools for iOS Development - specifically Instruments, like Leaks.

Is it a bad sign that an ipad app runs perfectly on the ipad but not in the simulator?

i've been developing an ipad app for quite some time now, all the previous versions run perfectly on both the simulator and the Ipad, but the newest version which is a major revamp of the app, runs super smooth on the ipad but has a lot of issues on the simulator (images not appearing, etc)
Is this a bad sign? Should i wait to make it work on both before submitting?
Thanks!
I would suggest that you be sure to test it on both versions of iPad and as many OS versions as you can. Be sure that you are running the same OS on both simulator and iPad (As I see in the comments that you say you are). Just to rule out any problems with using code that is incompatable with older OS's.
In general though, if your app is running fine on the hardware you shouldn't have anything to worry about. I would be much more concerned if it was the other way around.
It is almost always bad when an app does something you did not expect or design it to do. If you designed the app to run on both the Simulator and the iPad, and it doesn't run on one, there is possibly something seriously wrong with your design that could do other unknown things during app review, or worse, on many app user's devices (leading to lots of 1-star ratings).
Therefore you should figure out why something is going wrong, and preferably fix it (or at least understand what's happening well enough to determine how it will behave on your customer's iPads).
Some other suggestions:
make sure that both device and simulator are using the same internet connection
uninstall your app from simulator and device, and run clean on your project, and then do a fresh install

AVAudioPlayer: volume buttons work on some devices and not others

I have an app that uses AVAudioPlayer to play some embedded MP3 files. The volume buttons work reliably on the 3GS I mostly use for testing -- they worked under 4.1 and work now after upgrading to 4.3.1. On my boss's iPhone 4 running 4.2.1, they don't seem to work in our app at at all; and on the iPod Touch (also running 4.2.1) that's my secondary test machine, I've been able to get them to work once but can't reproduce how I did it.
I tried a hack I found, creating a dummy AVAudioPlayer at application startup but leaving it in prepareToPlay state, and found I was able to use the volume buttons on my initial screen, but once I was playing real audio they stopped working.
Anyone run into this? Any ideas why it works on some phones and not others?
Update: I updated the Touch to 4.3.1 and the problem went away. I assume therefore it's probably a bug in 4.2.1, but I'd still like to know if anyone's seen it and/or can point me to a bug report.
I had same problem. I found that the YouTube App was setting the default volume on the AVAudioPlayer. Found this with iPhone 4.3.3 so I am not sure if you are out of the woods yet.

iPhone Simulator Intermittent Slowdown

Almost every time I use the iPhone Simulator, I get intermittent slowdowns. Everything is running smooth and then the whole UI randomly drops down to 1-5fps. View pushes, animations and everything related to the UI just becomes sluggish for 2-10 seconds. Then all of sudden it comes back to normal again.
I've googled this issue several times and just can't find a solution. My guess is that there's some 3rd party extension/plugin that's causing this slowdown, but I'm not sure how to debug this.
This has been the case for the last 4 SDK installations. Happens on all simulators (iPhone, iPhone 4 and iPad). Happens in my own apps as well as in Apple's stock apps (Photos, Safari, Settings) and even in the Home Screen.
This issue makes debugging/testing extremely annoying. Any guess what could be the issue?
Ended up deleting everything in the ~/Library/Application Support/iPhone Simulator folder. It had some really old folders back from the 3.0 days. Maybe some incompatibility, I'm not sure.
Haven't had the issue since.
EDIT: Nope, this is only a temporary fix. Still looking for a permanent solution.
I know it's been a while, but it seems like Xcode 4.2 fixed this for good.
I noticed some slowdowns in the simulator when FaceTime for Mac is running, but it's not as bad as you describe. Have you tried when nothing else is running on your Mac?
Total long shot: Are you using Core Location at all? (GPS Stuff)?
I have seen the same kind of behavior your are talking about when I turn location tracking on inside my simulated iPhone app.