iPhone device vs. iPhone simulator - iphone

I have heard of apps not working properly on the simulator but working properly on the actual iPhone device. Has anyone experienced an app that runs perfectly in the simulator but not on the actual iPhone device?

Filenames are case-sensitive on the iPhone, but not in the simulator.
So, for example, if you try to load an image with UIImage *iconImage = [UIImage imageNamed:"MyIcon.png"], but your resource is actually named "myicon.png", then it will work on the simulator, but not on the device.

If your app is graphics intensive, like say a game, the performance of the simulator DOES NOT resemble at all that of the hardware. Your application will probably be smooth and work great on the simulator, but on hardware it'll likely render at a crawl unless you know what your doing. You can easily go from 60fps to 3fps between Simulator and hardware.

The order in which function/constructor parameters are evaluated is different:
int i = 0;
int f() { return ++i; }
int a, b;
int test(int p1, int p2) {
a = p1;
b = p2;
}
test( f(), f() );
//simulator: a = 2, b = 1
//device: a = 1, b = 2

Trigonometry functions may return different results:
float a = cosf( 0.108271248639 );
printf("%.12f", a);
//simulator: 0.994144439697
//device: 0.994144380093

I know there are some differences in the OpenGL ES implementation between the device and the simulator. From what I understand this is mainly because of the graphics chip on the iPhone (PowerVR MBX) having vastly different capabilities than other mac machines. Many of the hardware limits are not enforced in the simulator, so it is entirely possible to get something running in the simulator that will totally crash on the device.
There are also some OpenGL ES extensions that are supported by the iPhone hardware that are not supported in the simulator. I believe the major one is PowerVR texture compression (PVRTC).
Another problem area can be memory footprint. Anecdotally, I have not seen the simulator automatically enforce the memory limitations of the device. Therefore, it is possible to have something that runs in the simulator fine, happily consuming copious amounts of RAM and never bothering to free any of it only to be swiftly terminated after a short continuance of such behaviour when running on a device.

There are certain bits of code that won't work on the simulator (using the iPhone Keychain, for example), but for almost all applications, the simulator will work exactly like the iPhone.
That said, there's absolutely no replacement for testing on a real device.

I had a problem running a relatively simple 1/30 sec timer to do updates for a game. It runs fine in the simulator, and freezes out input on the device.

Also note that you will be compiling against the OS X frameworks (where applicable) when building for the simulator so you could be using methods and classes that aren't available on the iPhone versions of the frameworks.
One example I can think of off the top of my head is NSPredicate. I was able to compile and run an app using NSPredicate in the simulator, but it wouldn't compile for the device since that class isn't available.

Fingertips are larger than the 1 pixel endpoint of a mouse cursor. To do proper, even minimal, usability testing you should deploy your App to a device.

If you enable GCC_ENABLE_FLOATING_POINT_LIBRARY_CALLS, your app will crash all over the place in the simulator but work on the iPhone.
Quartz graphics calls in the iPhone simulator are faster than Java2D calls on the same computer--wicked fast.

I've had issues in memory-hungry applications where the Simulator would work just fine (because it would assume the iPhone/iPod Touch's memory was all yours to play with), while the device would crash (because other apps had leaked and Apple background services had eaten up some memory) and I hadn't implemented proper memory management or a response to the didReceiveMemoryWarning selector.

One big thing that took me a while to spot was that the simulator does not support device tokens, so any code that involves those will not run on the simulator.
I had a bug where the app would work fine on the simulator, but would crash when I ran it on a device because there was a bug in the device token code. I couldn't figure it out for the longest time!

There are many trivial examples. For example you can allocate far more memory on the simulator than on a real phone. You cannot receive push notification on the simulator if you don't have a retina Mac, the display dot pitch is different.
At a more fundamental level, the simulator is just that, it simulates the iPhone OS X using Mac OS X. This is evidenced by the fact that the filesystem on the simulator may not be case sensitive but on the phone it will be. More subtly, it does not emulate hardware so things like location will not work the same and 3D is going to be very different - especially if you are using Metal.
You should always test on real hardware.

Without considering the performance differences between the two, there used to be some things that the simulator didn't do correctly - i.e. it would mess up audio in some cases (see this question). However since the 2.2 SDK this issue has been resolved and the sound seems to be fine in the simulator. That's not to say that there is some other incompatibilities lurking down there! (Just none I've run into)

Regarding sounds, I was having the same problem. The issue was that the sound encodings that the Simulator supports is a different set of sounds than the device. I hope that helps.

I had many problems with libraries and frameworks when moving from the simulator to the device. Not least that they seem to have different architectures!

I have seen the positioning of objects, like toolbars be different on simulator than on the phone. Very annoying.

Yeah....
Apps compiled for 2.x will work fine on 3.0 device, but it will crash on 3.0Simulator
Note: 1. If you compile for 3.0, app will work fine on 3.0 simulator also...
2. a)Compile for 2.x and launch the app in simulator.
b)Now change the iPhone Simulator Hardware to "3.0".
c)Then launch the app we installed earlier in step a).
CRASH !!!!!!!!

movie file (m4v type) as my exprience is first time playing properly
but at second time it flickers screen of simulator...
whereas in iPhone device it works fime...

I had some sound effects that played fine in the simulator, but not on the device. I had to change the format to something that the device would handle.

If status bar of application is hidden,In case of simulator it still consumes touch event. But in the device it behaves perfectly.

Yes - it happened to me the other day. I'm new to the iphone, and so had deleted MainWindow.xib thinking it was unused. The app worked perfectly on the simulator - but crashed when installing on the phone.
Another issue we ran into was our three20 dependencies, which were set to ios 3.2 instead of 4.1. Worked perfectly in the simulator, but bombed on the device (since the files were compiled for the wrong arch).

iphone video library is not accessible
in simulator but code work fine on
actual device

Resource loading in the simulator is MUCH faster than in the device. For example, loading and displaying a sequence of full-screen UIImages (like a rudimentary video) can look very smooth in the simulator, and choppy on a device.
In fact, remember that there is a huge speed difference between different devices. The original iPhone and the iPhone 3G are slower than the iPod touch 2nd Gen, which is also much slower than the iPhone 3GS, and so on.

When trying to access the UIDevice.currentDevice(), it returns iOS Simulator instead of the actual device you're testing. This sucks, since you can't do certain things on the simulator.

Related

No Sound on iPhone Simulator - xcode 10, Swift 4 [duplicate]

Somehow my iPhone Simulator is unable to play sounds. First an app I'm working on using AudioServicesPlaySystemSound() stopped working.. I spent a while debugging this but sound is still working on the iPhone when I run the app on the device. I get the same results with other iPhone apps such as the sample Crash Landing app.
I can't find a sound setting anywhere in the simulator or Xcode preferences. I've tried resetting the simulator through "Reset Content and Settings" menu item to no avail.
On your Mac, go to System Preferences > Sound > Sound Effects and then uncheck and recheck "Play user interface sound effects".
You need to re-activate your system sounds, see the end of this page.
I had no sound in the simulator, so I tested it with mobile safari and tried playing an mp3: No sound!
All the above tips didn't help. Eventually, I changed my INPUT source from the virtual soundflower device to Line-In, and the Simulator worked!
So, even if the app wasn't using input, it didn't work well with Soundflower.
I've seen this problem after my update from OSX10.5.7 to 10.6.2
And I made the following changes to make the simulater sing again:
Goto "Applications/Utilities" and run "Audio MIDI Setup", then change midi format from 48000 to 44100.
OpenAL not working on the simulator was fixed with the 2.1 SDK. Make sure Active SDK and Active Executable are set to 2.1.
By the way, make sure you're using the last version of CrashLanding (v1.8). Some nasty leaks in SoundEngine were fixed recently.
I've found sound to be very inconsistent in the simulator (2.1 SDK). Sometimes it works, sometimes it doesn't. Even when it does work, it's usually very choppy and distorted (when playing audio files such as mp3).
A few things to remember:
call AudioSessionInitialize as soon as your app finishes launching
set the kAudioSessionProperty_AudioCategory property for the session via AudioSessionSetProperty (with a value such as kAudioSessionCategory_MediaPlayback)
call AudioSessionSetActive(YES)
Of course when all else fails, just run it on your hardware!
EDIT: Now that the 2.2 SDK has been released, I haven't had any problems with sound in the simulator. They must have fixed the bugs! I highly recommend you upgrade to the 2.2 SDK.
if reactivating system sounds didn't work for you try this:
launch audio-midi-setup, then configure your "built in output" to use 44.100Hz, 2 channels, 24 bits. (from http://www.cocos2d-iphone.org/forum/topic/4159)
somehow after a few days, my iphone simulator now wants 48.000Hz, 2 channels, 24 bits.
just play with it for a bit and be warned that it might change randomly when plugging in headphones, going to standby, restarting, etc.
and here's a an off-topic hint: when you plug headphones into your iphone/ipad the buffer size might double (e.g. from 512bytes to 1024 bytes), make sure you don't rely on the buffersize you requested!
I'm encountering this issue while running a watchOS simulator. In my case, the following worked:
Close the simulator in which the sound doesn't work.
Open another watchOS simulator.
Close it and reopen the original one.
Here are two other possible reasons why sound might not play on simulator devices:
With Xcode 14.2 and simulators running iPadOS 16 / iOS 16, I noticed that sound was playing on iPad simulators, but not iPhone simulators. It turned out that this was related to the AVAudioSession.Category being set on the AVAudioSession. If the category is .ambient then sound plays on iPad but not iPhone simulators, if the category is .playback then it plays on both. Interestingly, this does not seems to be a issue for iOS 15, here .ambient category plays on iPhone simulators too.
If you are calling AVAudioPlayer.play(atTime: TimeInterval) then the TimeInterval you pass in must be later than the device's current time. Passing 0 will not work and just plays nothing. Even passing a value > 0 may play nothing, you need to add the time offset to the deviceCurrentTime on the player. See the associated documentation for an example. This applies to real devices too of course, not just simulators.

IOS 6.0 ignores my launch image

I have been trying to get my app to work for the iPhone, after successfully getting it into the Google play store. I am finding the process for iPhone to be worse than I even expected.
My problem duJour is that though I have launch images specified for every display, when I test in the IOS 6.0 simulator OR on an iPhone 5 I get the stupid default launch image and not the one I specified.
I assumed I had something mis-configured, but when I got the idea of trying it on the IOS 5.0 simulator it WORKED! This is extremely frustrating.
I am using XCODE to do this 'visually'. I am too much of a noob to be sure how to do this manually in the .plist and I cannot find any real documentation from apple about it.
I could sure use a link to some actual useful documentation, or even some help from someone who has experienced the same thing and found a solution.
Thanks!
BTW: I am using xcode 4.5.2
A few things to check...
First, your naming conventions:
Default.png (320 x 480) for support of the original iPhone thru iPhone 3GS
Default#2x.png (640 x 960) for support of the iPhone 4 and 4S
Default-568h#2x.png (640 x 1136) for support of the iPhone 5
CaPiTaLiZaTiOn counts, so be careful.
Second, make sure each image is 72 dpi.
Third, do a Product->Clean from Xcode to make sure you've gotten rid of any old files lying around. Also delete the app from the simulator and try running again.
Finally, try running on actual hardware. Although the simulator is pretty good, there are a few differences in the way they work -- particular with how accommodating they are with images.

glDrawElements incorrectly renders points on iPhone

I am fairly new to OpenGL development on iOS. I'm working on software that will create 3D reconstructions of objects in the form of *.ply files. I'm trying to make an iOS app to visualize these simple vertex-only *.ply files. Everything works as intended on the iPhone and iPad Simulator, but when I run it on my iPhone, the points rendered in the view are glitchy and covered with large squares. Here's the comparison: iPhone and simulator. Has anyone run into similar issues with OpenGL?
It's important to understand that when running OpenGL ES code on the simulator, you're actually running it on the simulator's software implementation and not on the GPU.
The simulator's implementation is close to, but not identical to the implementation on the device GPU. This means that faulty code may render fine on the simulator. I've experienced it myself on a couple of occasions, like when using glbuffers and not allocating enough storage.
It's obviously hard to say where your code goes wrong, but I'd suggest you to go through your code and look for subtle errors.

Color-depth in iPhone simulator

I made a promotional video for my Exoplanet app and just noticed that the color-depth on the iPhone simulator is much lower than on the physical device. The visualizations look splendid on the actual phone but rather cheap on the simulator. I mainly notice this when using textures in OpenGL and CoreAnimation.
Have a look at this short video to see what I mean. (It has nothing to do with the recording.)
Am I doing something wrong? Can I increase the color-depth of the simulator?

App works on iphone simulator,iphone device, ipad simulator but not ipad device

So I made an app, And it runs on all possible platforms except the ipad device. I would understand if it ran on the ipad device and not the iphone device since the processor is better on the ipad, but this has me stumped. It also worked fine on the ipad simulator. Can anyone think of a reason why this could be?
There are too few details to give an explanation. A possibility is: when you run the app in two different devices, iPhone and iPad, some nib files could be different. Even the app delegate is different if you use XCode templates for universal apps. So this means that it is possible that the code executed is different in the two devices.
So imagine that in the iPad app delegate / view controller you're allocating - at launch - a lot of memory (scroll view with many large images for example). Then the app will not crash in the simulator (it uses your Mac memory). The app will not crash in the iPhone (different code). So at the end it will crash in the iPad only.
Other possibilities: you're going short in memory very soon. But the iPad 1 has less memory than iPhone 4G.
Other possibility: the watchdog timer kills your app at launch. It happens on the iPad 1 only because you're loading a few large images and it takes a lot of time, just enough to be killed by the watchdog.
Other possibility: iPad 1 is still with iOS 3.2, while iPhone and simulator are linked to iOS 4.0. In this case it is easy to have the app crashing in iPad 1 by calling one of the many new APIs introduced with iOS 4.
As you can see there are many possible explanations...
add target for device or convert it to universal application
Yes, it's easy to target both platforms. If you login to ADC and read the Programming Guide, it'll provide the basics for specific development. I can't legally speak of the "how."
Um. If you follow their directions, build two targets, share your source within the same project... then you'll be set. It's the same SDK, just different Nibs & main(), from what I can tell.
You say different xibs... you might be missing an Outlet connection somewhere.
Ok gents, sorry but I did not provide enough information for any of you to correctly answer this, but! here was my problem.
I had a login screen with 2 textfields, and a submit button. The submit button would release the current view and add a new view. I would usually press submit while the keyboard is being shown. Aparantly this makes everything blow up. You must manually hide the keyboard first. Hopefully this saves somebody some time.