Finally, I did exactly what
joe espindola said and the problem solved. Thanksjoe espindola!
And actually there’s one gotcha thing here.
If I use the build_native.sh to build the original android project created inside the Cocos2d-X folder, it compiles well.
However, if I copied and merged the same android project inside the newly created iPhone project, it started reporting missing Box2D.h errors. @joe espindola ’s solution was able to fix that.
As it turns out, the cpp files (let’s call them files A) in the /Classes folder inside the newly created iPhone project are different from the cpp files (let’s call them files B) in the /Classes folder in the original android project.
Specifically, the gotcha thing is, files A has code like include “Box2D.h” while files B doesn’t. As a result, if I compile the code in the original android folder, it compiles well and no errors are found (because it doesn’t try to link Box2D). But if I compile the code in the newly created and merged iPhone project folder, “Box2D.h” is reported missing.