Android on Mac: The Hybrid iOS/Android Project

Today we are going to set up a project for both iOS and Android using the same directory structure.  We will be able to share all the common code for both platforms.  This will greatly reduce maintenance time over keeping two separate projects in sync.

We will be setting up a new Xcode project for iOS.  We will copy the needed android files from the project we created in the last post.

Fire up Xcode and create a new Cocos2dx project with the same name in a directory other that the Cocos2dx source tree.  I use ~/Projects for all my development projects and repositories.  In this case I’m using “” for the Bundle ID.

Now we will need to copy various files from the Android project to the Xcode project. Let’s set a few environment variables to reduce the clutter then copy over the needed files and directories.


cp -R ${DROIDPROJ}/ ${XCODEPROJ}/android
cp -R ${CC2DXROOT}/cocos2dx ${XCODEPROJ}/libs/
cp -R ${CC2DXROOT}/CocosDenshion ${XCODEPROJ}/libs

Within the android folder (~/Projects/project/project/android) you copied to you Xcode project you will need to make the following edits to


Now you can verify that we didn’t break anything. Build and test the project within Xcode as normal. Also build and test the android project as we did in the previous post. Make sure you are inside the android directory of the Xcode project!

Next post we will discuss setting up Xcode so that we can do at least some of these steps for Android within Xcode itself!

  1. Android on Mac: Cocos2dx, Android SDK and CrystaX NDK
  2. Android on Mac: The Hybrid iOS/Android Project

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>