Is it possible to link a xcframework (FirebaseCore.xcframework) using cmake for Xcode 11 without pod? I can't find an example

Viewed 1028

Try to integrate firebase 6.23.0 using CMake in cocos2d-x 4.0 is there an example availiable.

2 Answers

You can do below work around to use latest firebase sdks.

Try to use framework directly from specific folder. For example for FirebaseCore add framework directly FirebaseCore.framework from this directory

"FirebaseCore.xcframework/ios-armv7_arm64/FirebaseCore.framework"

Add all frameworks from specific arch like for iOS device ios-armv7_arm64.

Then in cmake you will need to add frameworks like you add any other iOS native framework.

set(ios_frameworks 
FirebaseCore
FirebaseCoreDiagnostics
FirebaseInstallations
FirebaseInstanceID
FirebaseMessaging
GoogleAppMeasurement
FIRAnalyticsConnector
FirebaseAnalytics
GoogleDataTransport
GoogleDataTransportCCTSupport
GoogleUtilities
PromisesObjC
Protobuf
nanopb
FirebaseCrashlytics
)

Hope this will help.

For now i used (found samwhere else) not working for xcframework:

MESSAGE(STATUS "Firebase in: ${CMAKE_FIREBASE}")
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)

macro(ADD_FRAMEWORK fwname appname)
    MESSAGE(STATUS "MACRO ADD_FRAMEWORK firebase ${CMAKE_FIREBASE} ${fwname} ${appname} !!!")
    set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
    find_library(FRAMEWORK_${fwname}
        NAMES ${fwname}
        PATHS ${CMAKE_FIREBASE}  
        PATH_SUFFIXES framework xcframework
        NO_DEFAULT_PATH)
    set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
    if( ${FRAMEWORK_${fwname}} STREQUAL FRAMEWORK_${fwname}-NOTFOUND)
        MESSAGE(ERROR ": Framework ${fwname} not found")
    else()
        TARGET_LINK_LIBRARIES(${appname} ${FRAMEWORK_${fwname}})
        MESSAGE(STATUS "Framework ${fwname} found at ${FRAMEWORK_${fwname}}")
    endif()
endmacro(ADD_FRAMEWORK)

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

endif()
SET(CMAKE_FIREBASE ${CMAKE_CURRENT_SOURCE_DIR}/../Firebase/FirebaseAnalytics)

ADD_FRAMEWORK(FIRAnalyticsConnector  ${APP_NAME})
ADD_FRAMEWORK(FirebaseAnalytics ${APP_NAME})
ADD_FRAMEWORK(FirebaseCore ${APP_NAME})
#ADD_FRAMEWORK(FirebaseCoreDiagnostics ${APP_NAME})

The FirebaseCore FrameWork is a .xcframework and give a "not found" error.

Files

Related