First: open the XCode.tar.gz archive in the SDL_mixer sources, and load the project file in Xcode.
Second: go the project preferences and modify the base sdk and architecture like in the picture

Third: Expand the Targets label on the left and double click on Static Library; this will show the specific target options. Select the Preprocessor macros doubleclicking it and modify it by removing MID_MUSIC, MOD_MUSIC and USE_NATIVE_MIDI and add __IPHONEOS__ definition.

Sound great doesn't it? However here is bad news: for our application to correcly load OGG file (and most likely mp3 as well but i haven't tested it) we'll need another library to correctly link the various ogg functions. Don't worry, I'll guide you!
We have two options:
1- we can download ogg and vorbis and compile them from command line, set up the dependencies between the two, fix the paths and so on... if you're eager to try the command line is this:
< ./configure --prefix=/usr/local/iphone --host=arm-apple-darwin --enable-static=yes --enable-shared=no CC=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin9-gcc-4.2.1 CFLAGS="-pipe -mdynamic-no-pic -std=c99 -Wno-trigraphs -fpascal-strings -fasm-blocks -O2 -Wreturn-type -Wunused-variable -fmessage-length=0 -fvisibility=hidden -miphoneos-version-min=3.1 -gdwarf-2 -I/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.sdk/usr/include/libxml2 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.sdk" CPP=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cpp AR=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ar LDFLAGS="-isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.sdk -Wl,-dead_strip -miphoneos-version-min=3.1" >
2- we can simply use Tremor, which is an ogg implementation designed for memory constrained device with only integer operations: perfect for the iphone!
It comes bundled in another project, Cocos2d, a great framework for games. If you download it and select the libvorbis target, you will get a single decoding library statically linked for the iphone. It's compile time again!
Place both libraries in the Frameworks folder of your application and... Enjoy your ogg audio on the iphone!
Please drop a comment for critics and suggestions (and appreciations too :) )
Vittorio
No comments:
Post a Comment