Help for Qt for iOS with AdMob implementation
-
Hi,
Can anyone please suggest an answer for my problem.
I am developing an iOS app using Qt and trying to implement AdMob.
I installed AdMob required frameworks using pod file, they are installed correctly and .xcworkspace has been successfully created.
But when I run the build .xcworkspace file in Xcode, then it is showing the errors saying It can not find these frameworks.
Is there anything I need to include in CMakeLists.txt file, please see CMakeLists.txt file.
cmake_minimum_required(VERSION 3.16) project(testing VERSION 0.1 LANGUAGES CXX) set(CMAKE_AUTOMOC ON) set(CMAKE_CXX_STANDARD_REQUIRED ON) find_package(Qt6 6.5 REQUIRED COMPONENTS Quick Core Widgets) qt_standard_project_setup(REQUIRES 6.5) qt_add_executable(apptesting main.cpp AdMobManager.m ) # qt_add_qml_module(apptesting # URI testing # VERSION 1.0 # QML_FILES # Main.qml # ) # Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1. # If you are developing for iOS or macOS you should consider setting an # explicit, fixed bundle identifier manually though. set_target_properties(apptesting PROPERTIES # MACOSX_BUNDLE_GUI_IDENTIFIER com.example.apptesting MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} MACOSX_BUNDLE TRUE WIN32_EXECUTABLE TRUE ) target_link_libraries(apptesting PUBLIC Qt6::Quick Qt6::Core Qt6::Widgets "-framework UIKit" "-framework FirebaseCore" "-framework GoogleMobileAds" ) # Enable ARC for Objective-C++ files set_source_files_properties(AdMobManager.mm PROPERTIES COMPILE_FLAGS "-fobjc-arc") #set(CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_MODULES YES) include(GNUInstallDirs) install(TARGETS apptesting BUNDLE DESTINATION . LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) qt_generate_deploy_qml_app_script( TARGET apptesting OUTPUT_SCRIPT deploy_script MACOS_BUNDLE_POST_BUILD NO_UNSUPPORTED_PLATFORM_ERROR DEPLOY_USER_QML_MODULES_ON_UNSUPPORTED_PLATFORM ) install(SCRIPT ${deploy_script})
Also I did below changes in Xcode.
- In my project's build settings:
-
Add the /usr/lib/swift path to Runpath Search Paths.
-
Add the -ObjC linker flag to Other Linker Flags.
Thanks.
-
Hi,
Intuitively I would say that you have to tell cmake where to find these framework so it can properly configure the build system.
-
@SGaist ,
I downloaded Google Mobile Ads manually, and I updated the CMakeLists.txt file, but still it is not working.
# Define the frameworks path set(FRAMEWORKS_DIR "${CMAKE_SOURCE_DIR}/ios_frameworks") # Add include directories target_include_directories(apptesting PUBLIC ${FRAMEWORKS_DIR} ) # Link the frameworks explicitly target_link_libraries(apptesting PUBLIC "-framework GoogleMobileAds" Qt6::Core Qt6::Quick Qt6::Widgets ) # Link the framework search paths set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -F${FRAMEWORKS_DIR}" )
or
should I consider the Google mobile ads which are in Pod in Xcode, but how can I use this location in CMakeLists.txt
-
-
What was it ? It might other people having the same issue as you.
-
I stored in GitHub, if anyone interested, you can have a look at it. Link below.
https://github.com/thirupathiadla/AdMob-for-iOS-with-Qt.git
Also, for Android link below.