Cocos2d-x Xcode config for iOS / Andriod
- Install Xcode, Android SDK/NDK
- Craete cocos 2d-x project in Xcode
- Update NDK_ROOT_LOCAL and ANDROID_SDK_ROOT in create-android-project.sh
- Run create-android-project.sh
- Copy generated proj.android folder into the iOS project root
- Copy platform/android/java/src/org/cocos2dx/lib/* into proj.android/src/org/cocos2dx/lib/*
- Update COCOS2DX_ROOT in build_native.sh
- Use Eclipse, or create a new target for Android in the Xcode project … I created a new target as ‘external build system’ which calls build_android_ver.sh.
#!/bin/sh function test_ret_code(){ ▸ ret=$? ▸ if [ $ret -ne 0 ]; then ▸ ▸ echo "error: $1 failed, ret:$ret" ▸ ▸ exit 1 ▸ fi } export NDK_ROOT="/Users/sokoide/android-ndk-r8b" echo "*** custom build started" /Users/sokoide/Projects/iPhone/Spike/c2dxspike/c2dxspike/proj.android/build_native.sh test_ret_code "build_native.sh" /usr/bin/ant -f /Users/sokoide/Projects/iPhone/Spike/c2dxspike/c2dxspike/proj.android/build.xml debug install test_ret_code "install" /Users/sokoide/android-sdks/platform-tools/adb shell am start -n com.sokoide.c2dx/.spike test_ret_code "adb shell am start" echo "*** custom build completed" exit 0
Test app on iOS (480×320) and Android (800×480). I scaled the background, but didn’t for the label on top.