SDKBOX Firebase with CMake on iOS

how do you compile iOS, plz show steps .

nothing special

for ios i used the sdkbox GUI to apply the plugin, which generatse me an Firebase folder including multiple .framework files
and a normal Firebase.framework file.

I’m using the cocos ios toolchain to generate cmake
and add:

find_library(F_FIREBASE PluginFirebase)
#same for <sdkbox> and <iap>

target_link_libraries(${APP_NAME} ${F_SYSCONF} ${F_STOREKIT} ${F_SDKBOX} ${F_IAP} ${F_FIREBASE})

at the end of my cmakefile, since this works for the IAP plugin.
for Firebase it says NOTFOUND for F_FIREBASE, so find_library doesn’t work as it should (like for PluginIAP) and therefore can’t even generated a xcode project…

I’ve tried once to directly use target_link_libraries on the PluginFirebase.framework/PluginFirebase file, but then i get a bunch of linker errors. when trying to build.

I’m not 100% sure what to do with the Firebase folder that get generated.
Do I have to add all the *.framework files in CMake myself?

btw: im on 3.17.1

my steps:
0. create a cocos2d-x cpp 3.17.1 project

  1. sdkbox import iap and firebase
  2. run command cocos compile -p ios

.

have you generated another xcode project to test ? If yes, why ?

But did you run it with CMake?

as far as i know sdkbox doesn’t add anything automatically to the CMakeLists.txt
I only know that some cmake stuf gets generated for Android but I still had to add it to the projeckt cmake file.

I’ll try it with a new project later today.

sorry i do not know how to run it with CMake for iOS .

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
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} ${F_IAP})
endif()

answer from https://github.com/cocos2d/cocos2d-x/pull/19230

IAP example:

yeah IAP is working for me as well, I only had issues with Firebase, I’ll give it a shot again.

plz ref to [the IAP CMake example] http://docs.sdkbox.com/en/qa/sdkbox-cmake/#iap-example to write your own firebase configure.
I’ll update our CMake patch.

Ok with those examples I’m able to find the libs. I was able to also find and implement the Review SDK, what was weird there, is an issues with the *.framework folder, seems like sometimes ends up only with an *.framework/Versions/A and Versions/Current folder , I’ve noticed the other plugins additionally have the plugin and its Header directly in *.framework/ *.framework/Headers, so I just took the once from /A or /Current and copied it to .framework/ , I don’t know if this approach is normal with those apple frameworks but it worked for the Ratings sdk

00

anyway, linking seems to be still an issue for the Firebase plugin:

Undefined symbols for architecture arm64:
  "_OBJC_CLASS_$_FIRAnalytics", referenced from:
      objc-class-ref in PluginFirebase(AnalyticsWrapper-05d729be4239de43e73e8499144bd3c246307bf80e74b2a40c2d534585c986e4.o)
  "_OBJC_CLASS_$_FIRApp", referenced from:
      objc-class-ref in PluginFirebase(AnalyticsWrapper-05d729be4239de43e73e8499144bd3c246307bf80e74b2a40c2d534585c986e4.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

my current cmake for this:

add_definitions(-DSDKBOX_ENABLED)

message(${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac)

find_host_library(F_FIREBASE

NAMES PluginFirebase

PATHS ${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac

)

message(STATUS "F_FIREBASE: ${F_FIREBASE}") # print find libs result

target_link_libraries(${APP_NAME} ${F_FIREBASE})

Idk if firebase needs to be handled differently in cmake since it comes with an additional firebase folder with some *.frameworks

It looks like we need to add more framework:

Firebase/Analytics/nanopb.framework
Firebase/Analytics/FIRAnalyticsConnector.framework
Firebase/Analytics/FirebaseAnalytics.framework
Firebase/Analytics/FirebaseCore.framework
Firebase/Analytics/FirebaseCoreDiagnostics.framework
Firebase/Analytics/FirebaseInstanceID.framework
Firebase/Analytics/GoogleAppMeasurement.framework
Firebase/Analytics/GoogleUtilities.framework

I do not like using cmake with xcode, because if you modify one line of cmakelists.txt, xcode will build whole project.

do you mean adding them the same way as the main framework?, I’ve tried this quickly yesterday and had the same issues.
But will try this again today, found some hints to update from XCode 10 to XCode11 could also work, even though I think this is unlikely

ah yes, i got a bunch of sqlite3 errors

**Showing Recent Messages**

: "_sqlite3_errmsg", referenced from:

: -[APMSqliteStore lastErrorMessage] in GoogleAppMeasurement(APMSqliteStore_0ed784bc5f04451d45128745e2fe2383.o)

: "_sqlite3_bind_blob", referenced from:

: ___47-[APMSqliteStore bindValues:toStatement:error:]_block_invoke in GoogleAppMeasurement(APMSqliteStore_0ed784bc5f04451d45128745e2fe2383.o)

: "_sqlite3_bind_double", referenced from:

: ___47-[APMSqliteStore bindValues:toStatement:error:]_block_invoke in GoogleAppMeasurement(APMSqliteStore_0ed784bc5f04451d45128745e2fe2383.o)

: "_sqlite3_bind_text", referenced from:

: ___47-[APMSqliteStore bindValues:toStatement:error:]_block_invoke in GoogleAppMeasurement(APMSqliteStore_0ed784bc5f04451d45128745e2fe2383.o)

: "_sqlite3_bind_null", referenced from:

: ___47-[APMSqliteStore bindValues:toStatement:error:]_block_invoke in GoogleAppMeasurement(APMSqliteStore_0ed784bc5f04451d45128745e2fe2383.o)

: "_sqlite3_bind_int64", referenced from:

: ___47-[APMSqliteStore bindValues:toStatement:error:]_block_invoke in GoogleAppMeasurement(APMSqliteStore_0ed784bc5f04451d45128745e2fe2383.o)

: "_sqlite3_column_int64", referenced from:

`indent preformatted text by 4 spaces`

The quick cmake test:

find_host_library(F_FIREBASE

NAMES PluginFirebase

PATHS ${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac

)

find_host_library(F_FIREBASE1

NAMES FIRAnalyticsConnector

PATHS ${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac/Firebase/Analytics

)

find_host_library(F_FIREBASE2

NAMES FirebaseAnalytics

PATHS ${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac/Firebase/Analytics

)

find_host_library(F_FIREBASE3

NAMES FirebaseCore

PATHS ${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac/Firebase/Analytics

)

find_host_library(F_FIREBASE4

NAMES FirebaseCoreDiagnostics

PATHS ${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac/Firebase/Analytics

)

find_host_library(F_FIREBASE5

NAMES FirebaseInstanceID

PATHS ${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac/Firebase/Analytics

)

find_host_library(F_FIREBASE6

NAMES GoogleAppMeasurement

PATHS ${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac/Firebase/Analytics

)

find_host_library(F_FIREBASE7

NAMES GoogleUtilities

PATHS ${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac/Firebase/Analytics

)

find_host_library(F_FIREBASE8

NAMES nanopb

PATHS ${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac/Firebase/Analytics

)

message(STATUS "F_REVIEW: ${F_REVIEW}") # print find libs result

message(STATUS "F_FIREBASE: ${F_FIREBASE}") # print find libs result

target_link_libraries(${APP_NAME} ${F_REVIEW} ${F_FIREBASE} ${F_FIREBASE1} ${F_FIREBASE2} ${F_FIREBASE3} ${F_FIREBASE4} ${F_FIREBASE5} ${F_FIREBASE6} ${F_FIREBASE7} ${F_FIREBASE8})

which is solved by simply reading the sdkbox firebase docu where it says make sure to add the sqlite3 lib xD

so adding

find_library(F_SQLITE3 SQLite3)
target_link_libraries(${APP_NAME} ${F_SQLITE3})

works to compile and link everything.

I’ll do some tests and post my cmake changes if everything works fine :o

Ok got firebase to work:

I had some crashes on start but the solution seems to add -ObjC to other linkerflags ,obviously i need to do this in cmake

here is what I use for 3.17.1

if(IOS)
    SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -ObjC") # Necessary for Firebase sdkbox plugin
endif()

# This macro lets you find library on the host system

macro(find_host_library)

set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)

find_library(${ARGN})

set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)

endmacro(find_host_library)

if(IOS)

set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY "")

include_directories(System/Library/Frameworks)

find_library(F_SQLITE3 SQLite3)

find_library(F_IAP PluginIAP)

find_library(F_SDKBOX sdkbox)

find_library(F_SYSCONF SystemConfiguration)

find_library(F_STOREKIT StoreKit)

target_link_libraries(${APP_NAME} ${F_SYSCONF} ${F_STOREKIT} ${F_SQLITE3} ${F_SDKBOX} ${F_IAP})

add_definitions(-DSDKBOX_ENABLED)

message(${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac)

find_host_library(F_REVIEW

NAMES PluginReview

PATHS ${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac

)

find_host_library(F_FIREBASE

NAMES PluginFirebase

PATHS ${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac

)

find_host_library(F_FIREBASE1

NAMES FIRAnalyticsConnector

PATHS ${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac/Firebase/Analytics

)

find_host_library(F_FIREBASE2

NAMES FirebaseAnalytics

PATHS ${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac/Firebase/Analytics

)

find_host_library(F_FIREBASE3

NAMES FirebaseCore

PATHS ${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac/Firebase/Analytics

)

find_host_library(F_FIREBASE4

NAMES FirebaseCoreDiagnostics

PATHS ${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac/Firebase/Analytics

)

find_host_library(F_FIREBASE5

NAMES FirebaseInstanceID

PATHS ${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac/Firebase/Analytics

)

find_host_library(F_FIREBASE6

NAMES GoogleAppMeasurement

PATHS ${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac/Firebase/Analytics

)

find_host_library(F_FIREBASE7

NAMES GoogleUtilities

PATHS ${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac/Firebase/Analytics

)

find_host_library(F_FIREBASE8

NAMES nanopb

PATHS ${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac/Firebase/Analytics

)

message(STATUS "F_REVIEW: ${F_REVIEW}") # print find libs result
message(STATUS "F_FIREBASE: ${F_FIREBASE}") # print find libs result

target_link_libraries(${APP_NAME} ${F_REVIEW} ${F_FIREBASE} ${F_FIREBASE1} ${F_FIREBASE2} ${F_FIREBASE3} ${F_FIREBASE4} ${F_FIREBASE5} ${F_FIREBASE6} ${F_FIREBASE7} ${F_FIREBASE8})

endif()

as mentioned it seems like -ObjC is necessary for the Firebase SDK
also don’t forget to add GoogleService-Info.plist for the connection to the Firebase server
and additionally SQLITE3 has to be added

1 Like

Thanks for your resolution.

find_host_library is provided by the engine in 3.17.2

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