App Code Bug in combination with Cocos2d-x - Help Upvote

I am just trying out AppCode.

Actually scratch that, the iOS project still has errors in the AppCode editor, just different errors :rolling_eyes:

App Code ist a total let down as off now. They told me that the bugs that I found are severe and might take months for them to fix them.

They were even able to reproduce the issue with a very simple test project.

We can’t do much but vote and hope they finally do it.

Seems to parse OK when imported into CLion 2016.2 from CMakeLists.txt, if that helps anyone.

Which is odd since AppCode’s C++ support is supposed to based on CLion’s work.

I haven’t looked at how to make it run from CLion (is it possible?), but it should work to edit in CLion and run from Xcode…

I might finally have to learn CMake :wink:

Urgh, that doesn’t sound really fun to do, but definitely a good find!

Could you send a mail to JetBrains and tell them that you get it to work in CLion, referencing that other ticket?
They told me that it’s an underlying CLion bug, but maybe they’re on the wrong track here.

If you get it to work with CLion and CMakeList please report back how you did it :wink:

I had to tweak the cocos generated project CMakeLists.txt file just a bit, but this gets the macOS HelloWorld binary running with the absolute latest Cocos pulled from github:
http://pastebin.com/ABbUsA31

I added the following to the standard generated CMakeLists.txt:

if ( MACOSX )
  include_directories(
    ${COCOS2D_ROOT}/external/glfw3/include/mac
  )
endif( MACOSX )

...

if( MACOSX )
    pre_build(${APP_NAME}
    COMMAND ${CMAKE_COMMAND} -E remove_directory ${APP_BIN_DIR}
    COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/Resources ${APP_BIN_DIR}
    )
elseif ( WIN32 )...

Really not sure about the remove_directory in that last chunk :rolling_eyes:

iOS should be similar I think, but TBH this is probably enough for now.

Incidentally, I opened an old Cocos 3.3 project and the same code that’s causing problems pasted in parses fine…

AppCode 2016.2.3 + Cocos 3.3

AppCode 2016.2.3 + Cocos 3.13.1

Now that’s interesting…probably something in the header-import structure of Cocos2d-x changed that now triggers the bug.

Update: based on git tags, cocos2dx-3.10 is fine, cocos2dx-3.11 is not. Unfortunately that gap represents about five months of commits.

Seems to be the changes to CCPlatformConfig.h in this merge, but why they are breaking AppCode is not clear.

If I revert the changes above, AppCode is able to parse the HelloWorldScene.cpp without issue.

1 Like

Wow, you’re doing a really great job at track it down.

Are these changes in the CCPlatformConfig.h super relevant? Or just for better looks?

You should definitely share you findings with the guys at JetBrains / or link this thread. They might really benefit from it.

Done.

You can bodge the latest Cocos to work with AppCode by hardcoding CC_TARGET_PLATFORM in CCPlatformConfig.h as below. Run “File > Invalidate Caches / Restart” in AppCode after changing this.

“neater” solutions such as #define-ing out the Mac/iOS section don’t work. It seems you need to actually comment out those lines to avoid triggering the parsing bugs :rolling_eyes:

Awesome,

Wait…does this mean that the automatic setting for iOS and Android builds does no longer work if doing this?

Or did you find a way to detect Android otherwise?

No, it’s hardcoded for iOS. I’m not building for Android. You could try this:

// Apple: Mac and iOS
#if defined(__APPLE__) && !defined(ANDROID) // exclude android for binding generator.
//    #include <TargetConditionals.h>
//    #if TARGET_OS_IPHONE // TARGET_OS_IPHONE includes TARGET_OS_IOS TARGET_OS_TV and TARGET_OS_WATCH. see TargetConditionals.h
//        #undef  CC_TARGET_PLATFORM
//        #define CC_TARGET_PLATFORM         CC_PLATFORM_IOS
//    #elif TARGET_OS_MAC
//        #undef  CC_TARGET_PLATFORM
//        #define CC_TARGET_PLATFORM         CC_PLATFORM_MAC
//    #endif
    #undef  CC_TARGET_PLATFORM
    #define CC_TARGET_PLATFORM         CC_PLATFORM_IOS
#endif

It means it assumes iOS if you’re building on a Mac but not for Android, so maybe that will be OK for you.

1 Like

Thank you, I’ve tried this and it seems to work so far.

I even commented the TargetConditionals.h back in as I was a bit worried this might break something.

But it still seems to work.

Does it also work for you this way?

// Apple: Mac and iOS
#if defined(__APPLE__) && !defined(ANDROID) // exclude android for binding generator.
#include <TargetConditionals.h>
//#if TARGET_OS_IPHONE // TARGET_OS_IPHONE includes TARGET_OS_IOS TARGET_OS_TV and TARGET_OS_WATCH. see TargetConditionals.h
//#undef  CC_TARGET_PLATFORM
//#define CC_TARGET_PLATFORM         CC_PLATFORM_IOS
//#elif TARGET_OS_MAC
//#undef  CC_TARGET_PLATFORM
//        #define CC_TARGET_PLATFORM         CC_PLATFORM_MAC
//#endif

#undef  CC_TARGET_PLATFORM
#define CC_TARGET_PLATFORM         CC_PLATFORM_IOS
#endif

More or less. I’m still getting some parse errors now I’ve got a bit more code into the project :weary:

Your solution seems to work partially, the problem is that I need to build for Mac and for iOS.

I’ve just tried all sorts of trickery to define for IOS and MAC correctly, but nothing worked out.

As soon as I use TARGET_OS_IPHONE to determine it’s iOS, the issue appears.

Do you have an idea how I could overcome this?

Nope. Tried the same myself. AppCode is just a bit broken :confused:

Actually it looks like the problem is that the Base SDK for the libcocos2d tvOS project is set to “appletvos9.1” and shows as “not found” even though I have tvOS SDK 9.1 installed (or at least I think I do).

Changing it to “Latest tvOS (…)” allows AppCode to parse the project correctly.

The suggestion came from JetBrains.

2 Likes

Seems like we did it. I just hope we can use App Code now finally and there’s not any more other parsing errors anywhere.

Thanks for your investigations again @nivrig