Cocos2d-x for Android & iOS Development Environment configuration best practices

Source: Internet
Author: User
Tags macbook

This article is the continuation of my previous article. You can read it first.

These days have been studying the development of Cocos2d-x at the same time in Android and iOS, there are a few points of experience and inconvenience, Development Environment configuration please refer to the previous article.

Experience:

1. From the perspective of my small projects, from iOS to Android, cocos2d-x can achieve seamless migration. Written in Xcode, to eclipse packaging.

Inconvenience:

1. it may be that Xcode does not support importing code using file reference methods. I have been encountering strange issues during debugging. for example, if you do not start the simulator, and the simulator is black, the name of the application in the simulator is changed to $ {Product_name.

2. I cannot support git that comes with Xcode. I write code that relies heavily on git/svn, so that I can easily see the changed code.

3. eclipse does not configure single-step debugging, so it is best to debug it in Xcode and package it directly in eclipse.

The organizational structure of several test projects in the Code such as 2d-x is the best. If you can directly create project files for multiple platforms at one time from the script in the future.

Let's talk about the best practices for coexistence between Android and iOS projects.

Declare the version and path again:

Version: Cocos2d-x X: 10.8 Xcode: 4.5.1Eclipse: 4.2.1NDK: cocos2d-2.0-x-2.0.3OS: Samsung T959 cm10 (Android 4.1.2) file path: android-ndk-r8bDevice:/opt/Cocos2d-x SDK: /opt/android-sdk-macosxAndroid NDK:/opt/android-ndk-r8b if you refer to these paths below, replace them with your own path.

1. Create an Android project named CCMTest

Youngs-MacBook-Air :~ Young40 $ cd/opt/cocos2d-2.0-x-2.0.3/Youngs-MacBook-Air: cocos2d-2.0-x-2.0.3 young40 $. /create-android-project.sh use global definition of NDK_ROOT:/opt/android-ndk-r8buse global definition of ANDROID_SDK_ROOT:/opt/android-sdk-macosxInput package path. for example: org. cocos2dx. examplecom. young40... the output is omitted .. id: 2 or "android-10" Name: Android 2.3.3 Type: Platform API level: 10 Revision: 2 Skins: HVGA, QVGA, WQVGA400, WQVGA432, WVGA800 (default ), WVGA854 ABIs: armeabi ----------... the output is omitted .. input target id: 2 input your project name: CCMTest .... output omitted...
Youngs-MacBook-Air:cocos2d-2.0-x-2.0.3 young40$ cd CCMTest/Youngs-MacBook-Air:CCMTest young40$ lsClasses      Resources    proj.androidYoungs-MacBook-Air:CCMTest young40$ 

Then open the CCMTest directory and back up the directory proj. android (I copied a copy to the/opt/cocos2d-2.0-x-2.0.3 directory)

Then delete the CCMTest directory.

2. Create an Xcode project.

Create a project named "CCMTest" and save it in the/opt/cocos2d-2.0-x-2.0.3 directory.

If you did not delete the file in the previous step, Xcode will prompt you if you want to replace the file. It is also feasible to choose replace.

You can test that Xcode works normally.

3. Restore the proj. android directory

Restore the proj. android directory backed up in step 1 to the/opt/cocos2d-2.0-x-2.0.3/CCMTest directory.

At this time, if you try to compile with the command build_native.sh, it will certainly fail because the related files are missing.

Open the/opt/cocos2d-2.0-x-2.0.3/CCMTest/proj. android/jni/Android. mk file in your familiar Editor

Set the following lines:

To:

  

Open EDIT:/opt/cocos2d-2.0-x-2.0.3/CCMTest/proj. android/build_native.sh find

for file in "$APP_ROOT"/Resources/*

To:

for file in "$APP_ROOT"/"$APPNAME"/Resources/*

In this case, you can call the command to compile

Youngs-MacBook-Air:proj.android young40$ /opt/cocos2d-2.0-x-2.0.3/CCMTest/proj.android/build_native.sh 

 

Everything should be normal.

4. Create an Eclipse project.

Eclipse, Android, Cocos2d-x development environment, please refer to the previous article. I believe you should have been very familiar.

Import/opt/cocos2d-2.0-x-2.0.3/CCMTest/proj. android into Eclipse project.

If an error is reported in the project, see the previous article to eliminate the error message.

After importing the project, click Run to Run the project. (You may need to configure real machine debugging here)

Now, we can see that our test project is running on the real machine.

Because, cocos2d-x compatibility is very high, basically Xcode no problem, compile and package it into Android in Eclipse.

In addition, debugging configuration in Eclipse is very troublesome. Therefore, we recommend that you write it in Xcode, run the build_native.sh command, and then package it into Android using Eclipse directly.

 

If you have any questions, please contact us.

My weibo: http://weibo.com/young40

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.