[SOLVED] Use network extension in cocos2d-x 3.8 (iOS)

I’m trying to use HttpClient in my Cocos2d-x project. I’m using cocos2d-x 3.8 and developing with Xcode.

Some things I tried to do:

  • I was looking cocos-ext.h file and I saw network was removed. In this thread explains that it was moved to core: Why remove network on cocos2d-x 3.0 beta?

  • I saw in network/HttpAsynConnection-apple.h there are two namespaces declared, cocos2d and network

  • When I add this to my code the compiler says: no member named ‘network’ in namespace ‘cocos2d’

    cocos2d::network::HttpRequest* request = new cocos2d::network::HttpRequest();

Probably I’m missing something? I need to add any preprocessor macro to enable network? Some param in c++ compiler to enable sub-namespaces?

I read all documentation here, in cocos2d-x.org and Stackoverflow with no success.

Thank you very much!

You shouldn’t need to add any preprocessor macros or do anything with the compiler luckily.
Try #include "network/Request.h".

These sub-namespaced things (like extensions, ui) need to be included manually like this since #include "cocos2d.h" doesn’t automatically do it.

Thank you @Jgod, I can’t understand why I didn’t tried this before. Completely embarrassing.