Hi,
Can someone please suggest a answer for my problem.
I am developing an iOS app using Qt and I am trying to implement AdMob. I installed using below Pod file.
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'apptesting' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for apptesting
pod 'FirebaseAnalytics', '10.27.0'
pod 'Google-Mobile-Ads-SDK', '11.5.0'
end
and these are installed correctly and testing.xcworkspace is created successfully.
but when I run the build for xcworkspace in Xcode, it is showing below errors
'GoogleMobileAds/GoogleMobileAds.h' file not found
'FirebaseCore/FirebaseCore.h' file not found
please see CMakeLists.txt file for your reference
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 please see AdMobManger.m below
#import <UIKit/UIKit.h>
#import <FirebaseCore/FirebaseCore.h>
#import <GoogleMobileAds/GoogleMobileAds.h>
// Static variables for banner ads
static GADBannerView *bannerView = nil;
void initializeAdMob() {
// Initialize Firebase
if ([FIRApp defaultApp] == nil) {
[FIRApp configure];
}
// Initialize Google Mobile Ads SDK
[[GADMobileAds sharedInstance] startWithCompletionHandler:nil];
}
void showBannerAd() {
UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
UIViewController *rootViewController = keyWindow.rootViewController;
if (!bannerView) {
// Create the banner ad view
bannerView = [[GADBannerView alloc] initWithAdSize:GADAdSizeBanner];
bannerView.adUnitID = @"ca-app-pub-3940256099942544/2934735716"; // Test Ad Unit ID
bannerView.rootViewController = rootViewController;
// Position the banner at the bottom of the screen
CGSize screenSize = [UIScreen mainScreen].bounds.size;
bannerView.frame = CGRectMake(
(screenSize.width - bannerView.frame.size.width) / 2,
screenSize.height - bannerView.frame.size.height,
bannerView.frame.size.width,
bannerView.frame.size.height
);
[rootViewController.view addSubview:bannerView];
}
// Load the ad
GADRequest *request = [GADRequest request];
[bannerView loadRequest:request];
}
void hideBannerAd() {
if (bannerView) {
[bannerView removeFromSuperview];
bannerView = nil;
}
}
I also implemented below change
> In project's build settings:
> Add the /usr/lib/swift path to Runpath Search Paths.
> Add the -ObjC linker flag to Other Linker Flags.
Thanks
These Firebase Core and Google Mobile Ads are installed correctly, and xcworkspace has been created successfully. but when I run this workspace file in Xcode, it is giving errors saying It can not find Firebase Core and Google Mobile Ads.
Are there any settings in Xcode I should select.
Your help will be much appreciated.
Thanks,