XCodeiPhoneOS/README.txt
author Holmes Futrell <hfutrell@umail.ucsb.edu>
Fri, 18 Jul 2008 19:21:27 +0000
branchgsoc2008_iphone
changeset 2376 756e6e35d029
permissions -rw-r--r--
just a readme for the files located in this directory
hfutrell@2376
     1
==============================================================================
hfutrell@2376
     2
Building the Simple DirectMedia Layer with iPhone OS 2.0
hfutrell@2376
     3
==============================================================================
hfutrell@2376
     4
hfutrell@2376
     5
These instructions are for people who wish to use SDL to compile applications for iPhone OS 2.0.
hfutrell@2376
     6
hfutrell@2376
     7
To build SDL, simply open the XCode Project (XCodeiPhoneOS/SDLiPhoneOS/SDLiPhoneOS.xcodeproj), select the target, and hit 'build'.  You can also build in a CLI environment using the xcodebuild command line tool, if you wish. 
hfutrell@2376
     8
hfutrell@2376
     9
There are three build targets:
hfutrell@2376
    10
- StaticLibiPhoneOS:
hfutrell@2376
    11
	Build SDL as a statically linked (armv6) library for iPhone OS 2.0.
hfutrell@2376
    12
- StaticLibSimulator:
hfutrell@2376
    13
	Build SDL as a statically linked (x86) library for the iPhone Simulator
hfutrell@2376
    14
- Template:
hfutrell@2376
    15
	Package a project template together with freshly built libraries and copied headers.
hfutrell@2376
    16
  	The template includes proper references to the SDL library, skeleton code for a basic SDL program, and placeholder graphics for the application icon and startup screen.
hfutrell@2376
    17
hfutrell@2376
    18
==============================================================================
hfutrell@2376
    19
Using the Simple DirectMedia Layer with iPhone OS 2.0
hfutrell@2376
    20
==============================================================================
hfutrell@2376
    21
hfutrell@2376
    22
Here's probably the easiest method:
hfutrell@2376
    23
1.  Build the iPhone SDL Application template.
hfutrell@2376
    24
1.  Install the iPhone SDL Application template (recommended directory is /Developer/Platforms/iPhoneOS.platform/Developer/Library/XCode/Project Templates/SDL Application/)
hfutrell@2376
    25
2.  Start a new project using the template (SDL will be automatically included in your project)
hfutrell@2376
    26
hfutrell@2376
    27
Here's a more manual method:
hfutrell@2376
    28
1.  Create a new iPhone project
hfutrell@2376
    29
2.  Build the SDL libraries (libSDLiPhoneOS.a and libSDLSimulator.a) and include them in your project.  XCode will ignore the library that is not currently of the correct architecture, hence your app will work both on iPhone and in the iPhone Simulator.
hfutrell@2376
    30
3.  include the SDL header files in your project.
hfutrell@2376
    31
4.  Remove main.m and replace it with a new main.m (or main.c) which is coded like a normal SDL program.  To replace main.m with a main.c, you must tell XCode not to use the project prefix file, which includes references to Cocoa Touch.
hfutrell@2376
    32
==============================================================================
hfutrell@2376
    33
Notes -- reading and writing files
hfutrell@2376
    34
==============================================================================
hfutrell@2376
    35
hfutrell@2376
    36
Each application installed on iPhone resides in its own sandbox environment, including its own Application Home directory.  For each installed application, the system generates a unique name for the application home directory, which appears as a long, incomprehensible string of numbers.
hfutrell@2376
    37
hfutrell@2376
    38
Once your application is installed, the directory tree looks like:
hfutrell@2376
    39
hfutrell@2376
    40
MySDLApp Home/
hfutrell@2376
    41
	MySDLApp.app
hfutrell@2376
    42
	Documents/
hfutrell@2376
    43
	Library/
hfutrell@2376
    44
		Preferences/
hfutrell@2376
    45
	tmp/
hfutrell@2376
    46
hfutrell@2376
    47
When your SDL based iPhone application starts up, it sets the working directory to the main bundle (MySDLApp Home/MySDLApp.app), where your application resources are stored.  You cannot write to this directory, however -- instead, I advise you to write document files to "../Documents/" and preferences to "../Library/Preferences".  
hfutrell@2376
    48
hfutrell@2376
    49
More information on this subject is available here:
hfutrell@2376
    50
http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/ApplicationEnvironment/chapter_6_section_3.html#//apple_ref/doc/uid/TP40007072-CH7-SW21