iPhone App References

Document Sample
iPhone App References Powered By Docstoc
					TheBunny's #IphoneDev Faq v.25

Funny somehow Google found this FAQ on the server and now Im getting a lot of emails :)

Now that the NDA is lifted that is just fine.

Any how feel free to email with questions, ideas, errors or anything else you want in the FAQ at
chrisd@plaidworld.com

You can also find me on IRC freenode / #iphonedev as TheBunny

Also My Game company is www.plaidworld.com

My On going iphone game development blog is at www.bang2d.com

PS: Send anyone interested in investing in an iPhone/Mobile game company our way :)
        Our engine is already up and running on Mac/Win/Linux and iPhone.

Languages:

        Do I have to use ObjC on the Phone?

                 You can freely use C / C++ on the phone.
                 You still need to use ObjC to talk to the Cocoa APIs.
                 Feel free to wrap C++ code in ObjC call backs / events.

                 This page provides a summary of how Objective-C is implemented in C
                 using Apple's Objective-C runtime. Meaning you could call methods on ObjC objects
                 purely using C / C++ if you really wanted to.

                 http://www.cocoadev.com/index.pl?ImplementationOfObjectiveCInC


        How do I turn on ObjC++
                Change your file extensions to .mm

        Does Garbage Collection work on the phone?
                No.


Learning Cocoa / ObjC:

        Iphone Dev web sites
                http://iphonedevsdk.com/
                http://idevkit.com/

        Learning Objective C a primer
                http://developer.apple.com/iphone/gettingstarted/docs/objectivecprimer.action;jsessionid=6FA341

        MyFirst Iphone app:
                http://developer.apple.com/iphone/library/navigation/index.html

                 Under the "Getting Started" Tab
                         Read "Creating a iPhone Application"

        Introduction to The Objective-C 2.0 Programming Language:
                http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Introduction/chapter_1_sec

        Tutorials:
                http://www.cocoadev.com/index.pl?CocoaTutorials

                 http://www.cocoadevcentral.com

        Books:
                 Cocoa(R) Programming for Mac(R) OS X (3rd Edition) (Paperback)
                 by Aaron Hillegass (Author)
                 http://www.amazon.com/Cocoa-Programming-Mac-OS-3rd/dp/0321503619/ref=sr_1_1?ie=UTF8&s=books&qid
       Programming in Objective-C (Developer's Library) (Paperback)
               http://www.amazon.com/Programming-Objective-C-Developers-Library-Stephen/dp/0672325861


Developer Program:

1. 1. I just applied for the iPhone Dev program how long till I get in?
        Well thats a trick question... back in april I got in, in 2 weeks and
        I had a LLC and Company account.

        Other people still report not being accepted since the very beginning.

        Since the iPhone 2 launched I believe most developer world wide are getting in pretty fast.


2. I just paid apple 99$ how long will I have to wait till I get my certs?

   A: Maybe 24 hours.


What do I need to be able to test on the phone?

        You need to to pay apple 99$ after which you will be able to generate a provisioning
        certificate that will allow you to run code on the phone.


License Agreement:

        Will apple let me to this on the ???
                For starters read the SDK license agreement its written in very plain English.

        YOU CAN'T RUN SCRIPTS ON THE THE IPHONE!!!!
                a. You did not actually read the license did you?
                b. You are talking about license section 3.1
                c. The sections of the license you are talking about address 2 issues.
                        First is the use of plug ins or any kind of plug in like system.
                        Second you will not run any "DOWNLOADED" script.
                d. Mouse House my games is 95% Lua and is currently for sale in the App store.

Profiling:



Simulator:

        How do I simulate multi-touch?

                 Hold down option

                 If you hold option in the simulator,
                 you can pinch, as always,
                 but if you hold shift,
                 you can change the center point of the pinch.

        How do I swipe?

                 You can also hold shift and while holding it do a two finger swipe.


Hardware:

        Specs:

                 http://en.wikipedia.org/wiki/IPhone

                 CPU - 600 mhz ARM underclocked to 410 mhz
                 FPU - YES use it!
                 GPU - PowerVR MBX Lite 3D [24] with 24 MB of shared VRAM
                 Screen 480x320Â px, 3.5Â in (89Â mm), color LCD, 3:2 aspect ratio
                 Camera 2.0Â megapixel
                 Memory 128Â MB DRAM[26]
                 Storage Flash memory 4, 8, or 16Â GB

         How much free RAM do I really have to use?
                 Apple told me about 40 MBs.
                 If you have a better idea tell me?

Games:

         What version of GLES is on the phone:
                 OpenGL ES v1.1

         Game code:
                 GLSprite ( on web site )
                 CrashLanding ( on web site )
                 Touch Fighter 2 ( handed out at WWDC ask nicely on IRC maybe )

         What is the fastest way to draw on the iphone?
                 OpenGL.

         Best Practices for the GPU?

                 Get the
                 POWERVR MBX 3D Application Development Recommendations
                 and POWERVR Technology Overview

                 http://www.imgtec.com/powervr/insider/sdk/KhronosOpenGLES1xMBX.asp


         Tutorials:

                The OpenGL Red Book or NEHE is all you really need to learn GL
                and most of normal GL translates directly to GLES

                You can order the red book USED from amazon
                        http://www.amazon.com/gp/product/0321335732/ref=s9sdps_c6_14_img2-rfc_p-frt_p-3237_p_si

                 or here is at least 1 free HTML copy online.
                         http://fly.srk.fer.hr/~unreal/theredbook/

                 Possibly a much better GL book with all the same stuff and a lot more is
                         OpenGL(R) SuperBible:
                         http://www.amazon.com/OpenGL-SuperBible-Comprehensive-Tutorial-Reference/dp/0321498828/

                 GLES
                           http://www.imgtec.com/powervr/insider/sdk/KhronosOpenGLES2xSGX.asp

                           http://www.zeuscmd.com/tutorials/opengles/index.php

                 NeHe ( general OpenGL )
                         http://nehe.gamedev.net/

         iPhone Game Engines:

                Shiva 3D
                           Lua based 3D IDE host app is windows only(?)
                           Looks Cool tho
                           http://www.stonetrip.com/

                 2D engine for iphone using python
                         cocos2d:
                                  the PC/Mac/Linux coded in python (it doesn't work on iPhone)
                                  http://cocos2d.org

                                   iPhone version coded in objective-c
                                   http://code.google.com/p/cocos2d-iphone/

                 With the NDA lifted libSDL is coming to iPhone

                           http://www.libsdl.org/
                CVS http://www.libsdl.org/cgi/viewvc.cgi/trunk/

        Unity3D - excellent mac/win game engine coming to iphone this week.
                I can highly recommend this one. I work with ith daily doing fulltime contracting work.

                http://unity3d.com/unity/features/iphone-publishing

        Torque for iphone.
                http://www.garagegames.com/products/torque/iphone

                Interestingly Oolong 3D game Engine below says iTorque uses it.
                I have no idea what Garage Games actually added on top of Oolong

       Oolong 3D game Engine
               Open Source
               http://oolongengine.com/
               Used in this game http://sourceitsoftware.com/zombie.html

        Here is another open source engine that looks good.

                http://www.sio2interactive.com

                        Games Made with it are at: http://sio2interactive.com/GAMES.html

                        IRC channel is: sio2




How do I load a texture?
        See any of the above source code...
        There used to be a class that both loaded textures and could draw quads for you.
        I used it as a basis for my quad based engine.
        The code is plenty fast.

How do I draw a tile/quad?
        See GLSprite code.

How do I play sounds?
        Use OpenAL
        See CrashLanding for code.

        Also
        https://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingG


How Do I play music?

       See touch fighter 2 code SoundEngine.cpp

       AudioQueue for streaming audio music

       Also
       https://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingG

        Also ins SDK 2.2
                There is a new AV frameworks that lets you play music in like 4 lines of code
                http://arstechnica.com/journals/apple.ars/2008/11/25/iphone-sdk-watch-new-avfoundation-

Networking:
        Touch Fighter 2 code.

       Speed issues:
               I solved that wifi throttling back providing high latency by sending a udp packet out e
               If you top >100ms, the wifi power saves and you get ping times to the ipod touch of upt
         Using GL and cocoa views/layers at the same time:
                 See how the prefs are done in the Touch Fighter 2 code.

         Whatshould I set my timer to?

                 Don't use a timer.
                 Use a thread instead for the main game loop.

                 In some recent verison of the SDK the issues with threading GLES were fixed.

                 Your game loop should look something like this and might get a nice +10 FPS from useing
                 threads vs Timers.

                 - (void) applicationDidFinishLaunching:(UIApplication*)application{

                                 // SET UP GLOBAL
                                 the_app = self;

                                 [ self my_setup ];

                                 // TIMER
                                 //[ NSTimer scheduledTimerWithTimeInterval:( 1.0 / kFPS ) target:self selector:

                                 // START THREAD
                                 [NSThread detachNewThreadSelector: @selector( run_bang2d_threaded: ) toTarget:s


                         }


                 - (void) run_bang2d_threaded:(AppController*)sender {

                         NSAutoreleasePool*        pool = [ NSAutoreleasePool new ];

                         // SET CURRENT GL CONTEXT FOR THREAD
                         [ sender->_glView setCurrentContext ];


                         // RUN SDL / LUA LOOP
                         bool game_over = false;

                         // TERMINATE MAIN GAME LOOP TIMER
                         while( game_over == false ){
                                 //printf("RUN!\n");

                                 game_over = iphone_main( &iphone_events );

                         }

                         [pool release];

                 }




                 // OLD
                 a LOT higher then your actual desired max frame rate.
                 If you go to high the iphone will not get input. Say 1000 FPS.
                 If you go to low you will actually lose FPS while waiting for the timer to resume.
                 My games is currently set to around 500 fps.
                 If I set it to a steady 30 FPS or even 60 I lose an actual 5 FPS.
                 YMMV of course so play with it.



         PNGs:

                 Are the preferred image format on the iPhone.



5 of 9                                                                                          7/22/10 2:58 PM
               But they get converted by xcode.

               All your PNGs get converted to BGRA with Premultiplied alpha
               its basically an optimization to make images draw fastest
               but that only really applies if your using UIKit to draw them.

               So if you are using a PNG lib to load them instead of the iPhone APIs you need to
               add the build setting IPHONE_OPTIMIZE_OPTIONS=-skip-PNGs
               to any target that doesn't want the PNGs modified

               Ok Here is how you do that...

                       Go to your projects build settings.

                       In the lower left hand corner is a menu you icon that looks like a GEAR

                       Choose Add User-Defined Setting

                       Name the setting: IPHONE_OPTIMIZE_OPTIONS

                       Set the Value to: -skip-PNGs

                       Do a clean build and your good to go as far as I can tell.
                       I checked my bundle here and it worked.

                       Im not sure if you will have issues cause the icon is also not compressed and neither i

               more notes...

              1. Rename your images to something else (eg. .ppng), and the XCode packaging tool will ignore y
              2. According to the following link (http://www.imgtec.com/powervr/insider/sdk/KhronosOpenGLES1x
                      you need to add the following build settings definition for each target.
                      IPHONE_OPTIMIZE_OPTIONS=-skip-PNGs
              3. Teach your PNG decoder to handle Apple's CgBI format.
              4. Use the Cocoa UIImage classes or the Texture2D.m class.

              EVEN More notes

                       Is it possible to set an iPhone XCode project to skip the 'CompressResources' build ste
                       Specifically, I want to skip the stage where it runs pngcrush on all of my .png files,
                       of which don't survive the experience in a form which my app can read.
                       Edit: the version of pngcrush used creates png files which contain a non-standard
                       'mandatory,
                       private' chunk which explicitly prevents decoding. I've modified my png reader to handl
                       these
                       files, but I'd still like a per-project method of skipping this step. One of the other
                       effects
                       of pngcrush is that it doesn't save the colour value of transparent pixels, so alpha-ed
                       textures show fringing at smaller mip levels.
                       The iphone png format is described here: http://modmyi.com/wiki/index.php/Iphone_PNG_im
                       Skip the CgBI chunk
                       Skip the zlib headers
                       Swap BGR to RGB channel order

                       Edit: It appears it also premultiplies the alpha, so:
                       Divide by alpha



       LandScape Mode:
               How do I get my GL coordinate system in landscape mode?
                       Rotate your Camera -90


       How do I open a URL in Safari from my app?

              [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];


Metrics:
         Theres at least 2 libs Im aware that you can slap in your App and track users and metrics
         like time used and just about anything else you want like... how many users finished your game.

         http://www.pinchmedia.com
                 Nice easy to use lib for tracking metrics in your app Im told.

         http://www.mobclix.com/
                 This site also lets you see global itunes Rankings for you app and not just itunes top 100.
                 It also lists your rank over time.

                 See Mouse House for instance. http://www.mobclix.com/appstore/app/role-playing/mouse-house


Reviews:

         Theres a few sites that let you view all your itunes reviews world wide.

         http://www.moopf.com/appstorereviews/

         http://www.costmosoft.com/ratings.php


Sales Figures:

         Mouse House Sales
                 http://www.bang2d.com/

         Payday Roulettes
                 http://www.veiledgames.com/blog/

         http://www.medialets.com/blog/2008/07/15/app-store-pricing-by-category-score-card/

         http://www.losingfight.com/blog/2008/11/07/can-you-make-a-living-off-an-iphone-app/



Ad Based Revenue:

         http://www.pinchmedia.com

         http://www.admob.com/s/solutions/iphone

         http://www.medialets.com/iphone/sdks.php

Sound Samples:

         Good FREE sound sample sites.

         // NO LONGER FREE AS OF DEC 7th MEH :(
         http://www.soundsnap.com/

         http://www.findsounds.com/

         http://www.freesound.org/



Hacks:

///////////

         iphone tip of the day: start the simulator from the command line
         with MallocStackLogging=1,
         run app from xcode as usual, use leaks against your app's pid
         to get much more useful results than the crappy instruments stuff

///////////

         // To change the title of the back button when using a UINavigationItem, use this undocumented call:
          UINavigationItem *navCon = [self navigationItem];
          [navCon setBackButtonTitle:@"Cancel"];

          // This call works, but is not in the header, thus causing a "may not respond to" warning. Make the war

          @interface UINavigationItem (Hacks)

          - (void)setBackButtonTitle:(NSString*)title;

          @end

///////

To get the MinimumValueImage and MaximumValueImage to work with PSSliderSpecifier,
I had to open the Settings.bundle in the Finder using "Show Package Contents" and copy the png files in there.
Size didn't seem to make a difference, smaller ones worked OK.
The image files need to be in the Settings.bundle.
I could not get them in there using Xcode, had to do it by hand.

From: Â http://forums.macrumors.com/showthread.php?t=537644

////////

IAlertView, UIAlertSheet and UIAlert run non-modal
To get them modal, do this:
//We're exposing a private method (undocumented)

@interface UIAlertView (Synthesize)

- (void)setRunsModal:(BOOL)modal;

@end

  and then call: Â [alertView setRunsModal:YES] Â    before you "show" the alertView

///////

 it's really cool
Detects memory leaks
and wrong code.
Stuff that "leaks" and xcode miss
It works at the llvm level
http://clang.llvm.org/
Then, put this script in your project
#!/bin/sh
cd ~/Desktop/Projects/Svn/TouchPhysics
rm -rf build
~/Desktop/OSX\ Development\ Tools/Clang/scan-build  -k -V xcodebuild
(obviously change the paths)
Then "Clean your Project" and recompile by running this script instead
It will then popup the errors in Safari
YOu don't want to run it on every build (because it takes a little longer)
But just run it occasionally as you build stuff and want to do the check
It's a static checker, will find missing releases
Things like variables being reassigned before they are used (i.e. redudant code)
Pretty cool
Works great for iphone development too

//////

Quentarez:   here's a great tip:
Quentarez:   when creating a draggable view, animated the update of the position with a .01 animation
Quentarez:   CGPoint touchLocation = [touch locationInView:[self view]];
Quentarez:   [UIView beginAnimations:nil context:nil];
Quentarez:   [UIView setAnimationDuration:.01];
Quentarez:   [UIView setAnimationBeginsFromCurrentState:YES];
Quentarez:   [[viewTouch view] setCenter:touchLocation];
Quentarez:   [UIView commitAnimations];
Quentarez:   if you don't animate it, it's very jerky
Quentarez: with this it's smooth as silk

				
DOCUMENT INFO
Shared By:
Categories:
Tags: iphone, apps
Stats:
views:226
posted:7/28/2010
language:Czech
pages:9
Description: Learn to create iPhone Apps with these resources.