# xu4 for iOS #

This is a small document that tries to document how to use xu4 on iOS. It assumes some knowledge of iOS development and that you know how to use Xcode.

## Building ##

You can build xu4 for the iPad by using opening xu4.xcodeproj in the u4/src/iOS
directory and building the Ultima4-iPad application. Everything should be set
up for you aside from two missing references to ultima4.zip and u4upgrad.zip.
For these files, you will have to obtain from the well known places (i.e.,
check the xu4 web site). There shouldn't be much more magic than that.

The iOS code does use boost (boost.org) (specifically scoped_ptr and
intrusive_ptr). If this is a deal-breaker, I guess I could roll my own
versions, but really you just need to include the headers from boost. There's
no need for using any other parts of boost. My use of boost has not leaked into
the rest of xu4, though it probably won't hurt anything if it did.

## Hacking ##

The port uses no SDL. The tiles are handled using CGLayer. Event handling using
standard Cocoa Touch and sound using the AVFramework. Performance is excellent
with very little time spent optimizing the code.

Points in the code that needed to call-in to iOS code are all conditionally
compiled using the IOS macro. I strongly encourage everyone else uses this when
they are ifdef'ing as well. The patterns I used should be straightforward.

Files for iPad/iOS specific things like in the following:

* ios_helpers.(h|mm) -- Glue namespace for bridging C++ and Objective-C without
                        contaminating other xu4 source:

* Classes/iPad -- Folder for all the Objective-C sources for the iPad

* Resources/iPad -- Folder for all the iPad nibs

## Other Notes ##

I refactored the code for sound and music. I think this matches more the intent
of the original changes in January. That is, it hides the implementation
details into specific functions that are called by the backed that is chosen at
compile time. Adding your own file is simply a matter of creating your own
implementation of these functions and making sure that it is chosen during
compilation. Currently, the backends only SDL_Mixer and the AVFoundation on
iOS. If there is some other viable sound system, it would be neat to try and
add it as well as that would likely uncover any issues with my current level of
abstraction. No support for changing the backend at runtime is supported and I
would be hard pressed to see why this would be a good idea for xu4.


