6

The Xcode iPad simulator is not entirely consistent

 3 years ago
source link: http://rachelbythebay.com/w/2011/12/01/simulator/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

The Xcode iPad simulator is not entirely consistent

If you're new at the whole iOS, Xcode, Cocoa, CoreAudio, Objective C, Buzzword6, Buzzword7 thing like me, you probably need all the help you can get. Hopefully this will prove helpful to someone.

I've been working on something which needs to keep playing audio in the background. Most of my work has been happening in an iPad simulator which ships with Xcode. It's the same thing you get to use for free if you download a copy.

You need to be aware right now that this thing does not duplicate all of the behaviors of the real device. Oh no. It's far from it.

The little "playback" icon will not appear on the simulator even if you do the whole thing to beginReceivingRemoteControlEvents and becomeFirstResponder. You can do all of your homework and totally nail the code, but if you depend on the simulator, you will be chasing your own tail.

For this kind of stuff, you have to ship it to a real device. There, you will find that the icon appears up next to your battery charge % as it should. It's a pretty harsh way to learn a lesson!

It gets better. If you try to test backgrounding on the simulator, it will fail. Your app will just suspend itself when you hit the home button. Even if you did the whole "Required background modes" of "audio", it will just laugh at you. Again, you have to use a real device and then it will behave properly.

Also, beware any documentation on this topic, since it changes regularly. Things you read about may be for a version other than Xcode 4. Stuff gets moved around and defaults change. For one thing, being able to run in the background is now the default, and you have to explicitly tell it when your program should not try to run that way.

There. I just hope this saves someone else the trouble.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK