Getting SDKBOX to work with CMake

Sorry in advance for the noob-wtf-please-help-me-post.

SDKBOX seems a bit too good to be true. Has anyone gotten any of the plugins to work using cocos2d-x on both iOS and Android? I keep creating new git branches to test various plugins, but so far none of them compile on both iOS and Android out of the box, which is the selling point of SDKBOX. The biggest success has been with Google Analytics on iOS. It compiled. I have not gotten so far as to test the actual functionality as I cannot proceed until I can prove it will compile on both platforms. It will not compile on Android. (file not found #include “PluginGoogleAnalytics/PluginGoogleAnalytics.h”). Ok, so a dependency issue. How do I fix this? Here are some details:

Cocos2d-x v3.17.02
Using CMAKE v3.15.0-rc1
Android Gradle Plugin Version 3.4.1
Gradle Version 5.1.1

@R101 posted about this last year, but I think his solution either no longer works.

TL;DR SDKBOX plugin does not compile on Android. How do you add plugins when building using CMAKE?

It turns out that I had improperly followed the directions on this page. As for now, I get the analytics plugin to compile on iOS and Android. Now to test if they work…

https://docs.sdkbox.com/en/qa/sdkbox-cmake/

1 Like

I just got the latest SDKBOX (2.5.0) and have managed to get it to compile with the new cocos2d-x v4 on Android. I think using the GUI installer from the website put everything (libs and jar files) in their correct folders for me. Then I added the following to my CMakeLists.txt.

add PluginIAP lib

if(ANDROID)
add_definitions(-DSDKBOX_ENABLED)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/proj.android/app/jni/PluginIAP/)
target_link_libraries(${APP_NAME} ext_PluginIAP)
endif()

add sdkbox lib

if(ANDROID)
add_definitions(-DSDKBOX_ENABLED)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/proj.android/app/jni/sdkbox/)
target_link_libraries(${APP_NAME} ext_sdkbox)
endif()

Obviously if not using PluginIAP, change where you see PluginIAP to the name of the plugin you want to use.

We can ask @yinjimmy to help us

I’ll follow https://docs.cocos.com/cocos2d-x/manual/zh/installation/CMake-Guide.html and try iOS.

2 Likes

IAP works

update CMakeLists.txt

if(IOS)
add_definitions(-DSDKBOX_ENABLED)
message(${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac)
find_host_library(F_IAP
    NAMES PluginIAP
    PATHS ${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac
    )
message(STATUS "F_IAP: ${F_IAP}") # print find libs result
target_link_libraries(${APP_NAME} ${F_IAP} "-framework SystemConfiguration" "-framework StoreKit")
endif()

if(IOS)
find_host_library(F_SDKBOX
    NAMES sdkbox
    PATHS ${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac
    )
message(STATUS "F_SDKBOX: ${F_SDKBOX}") # print find libs result

target_link_libraries(${APP_NAME} ${F_SDKBOX})
endif()

generate xcode project command

~/test/cpp3171/ios-build [master] $ cmake .. -GXcode -DIOS_PLATFORM=SIMULATOR -DCMAKE_TOOLCHAIN_FILE=../cocos2d/CMake/ios.toolchain.cmake

compile with Xcode

Thanks,

2019.08.07.
Actually, I do not know why use CMake to generate Xcode project again.
There is a Xcode project in cpp3171.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.