How to make the Android NDK compile Objective-C! Many thanks to Jackie Gleason (@LifeIsTooShort) for his M3 Conference (@M3Conf) presentation, Adding Objective-C Support to the Android NDK, upon which most of this tutorial is based.

Download and Patch the Android NDK Toolchain Sources

Using the terminal, create a directory for your toolchain sources:

mkdir -p ~/SDKs/Android/toolchain-src
cd ~/SDKs/Android/toolchain-src

IMPORTANT: The build-gcc script expects a specific layout for the source directory. Create the above directory anywhere you like, but be sure to create the subdirectories below exactly as described. Next, fetch the sources:

git clone
git clone
git clone
git clone
git clone
mkdir binutils
cd binutils/
curl -O
tar xjfv binutils-2.22.51.tar.bz2
cd ../
mkdir gcc
cd gcc/
curl -O
tar xjfv gcc-4.6.1.tar.bz2
cd ../

Patch the toolchain makefile:

git clone git:// build-patch
cd build/
patch < ../build-patch/
cd ../

Patch GCC:

cd gcc/
curl > gcc-4.6.1.patch
cd gcc-4.6.1/
patch -p1 < ../gcc-4.6.1.patch

Download and Patch the Android NDK

Using the terminal, fetch the NDK:

cd ~/SDKs/Android/
curl -O
tar xjfv android-ndk-r6-darwin-x86.tar.bz2

Next, patch the build-gcc script:

git clone git:// android-ndk-build-gcc-patch
cd android-ndk-r6/build/tools/
patch < ../../../android-ndk-build-gcc-patch/

Build the Android NDK Toolchain

Using the terminal, get to the NDK build/tools directory:

cd ~/SDKs/Android/android-ndk-r6/build/tools/

Next, rebuild GCC on Mac OS X:

./ --gmp-version=4.2.4 --mpfr-version=2.4.1 --binutils-version=2.22.51 --try-64 ~/SDKs/Android/toolchain-src ~/SDKs/Android/android-ndk-r6 arm-linux-androideabi-4.6.1

Or rebuild GCC on Linux:

./ --gmp-version=4.2.4 --mpfr-version=2.4.1 --mpc-version=0.8.1 --binutils-version=2.22.51 --try-64 ~/SDKs/Android/toolchain-src ~/SDKs/Android/android-ndk-r6 arm-linux-androideabi-4.6.1