I updated Google AdMob SDK to 7.1.0 using Pods.
So in my appDelegate.m, I am trying to add this line
@import GoogleMobileAds;
But I
None of the other answers to date worked for me. This is what did:
Go to 'Build Phases', 'Link Binary with Libraries'. I had already added the GoogleMobileAds.framework
here, so I removed it and re-added it.
To add it, click the + sign for the 'Link Binary with Libraries' section and click 'Add Other...'. Navigate to where you've stored GoogleMobileAds.framework
and select it.
Make sure you've first added GoogleMobileAds.framework
to your project by going to 'File' > 'Add Files to your-project-name'.
That fixed the issue for me.
In case somebody is still occuring this error - check if in build settings field "Framework Search Paths" is filled with correct path to your framework
I was stuck with this problem for few hours, but graceful solution is finally found. My method doesn't use "manual files linking", only pure podfile usage.
I faced this problem when I have updated my pods ('pod install' or 'pod update') after adding another target to the project.
My solution is:
Go to your podfile and make sure you have defined "target ..." block for each target of your project (voila! seems like not documented, at least I didn't find it). For example you have 2 targets: "theApp" and "theApp Lite". In this case your pod file must look like this:
target 'theApp' do
# ...your pods and options here
end
target 'theApp Lite' do
# ...your pods and options here
end
Then do "pod install" or "pod update" to update your libraries.
Then go to each target's General settings and make sure you have proper (corresponding to you target) "libPods...a" (or "libPods...framework", in case you use "use_frameworks!" podfile option) file linked under "Linked Frameworks and Libraries" section. Remove garbage/wrong/confused links if any. Add manually if missing (must appear under "Workspace" group/dir when you hit "+").
Under "Build Phases" you should observe "[CP]"-prefixed items for each target.
After this I had no problems with building.
I deleted pod and install again... SOLVED my problem
rm -Rf Pods; pod install
in my project dir.
I leave a script that generates inject static frameworks
pod --version 1.3.1
Version 9.1 (9B55)
Podfile [Target]
target 'generic' do
#Google
pod 'GoogleAds-IMA-iOS-SDK', '~> 3.6.1'
pod 'Google-Mobile-Ads-SDK', '~> 7.25.0'
#pod Module 'GoogleMobileAds' not found
pod '#LIB_ERROR#'
sd
end
Podfile [Fuction]
def inject_frameworks(installer, targetName, listPaths)
def print_info(text)
puts "\e[33m[!] #{text}\e[0m"
end
installer.pods_project.targets.each do |target|
if target.name == targetName
print_info "Inject frameworks in #{target.name}"
config = target.build_configurations.first
if config
xcconfig_path = config.base_configuration_reference.real_path
build_settings = Hash[*File.read(xcconfig_path).lines.map{|x| x.split(/\s*=\s*/, 2)}.flatten]
frameworks_paths = Array.new
if build_settings['FRAMEWORK_SEARCH_PATHS']
frameworks_paths.concat(build_settings['FRAMEWORK_SEARCH_PATHS'].delete!("\n").split(/ /))
end
listPaths.each do |frameworks_path|
print_info "[#{target.name}] Add search path frameworks #{File.dirname frameworks_path}"
frameworks_paths.push(File.dirname frameworks_path)
end
build_settings['FRAMEWORK_SEARCH_PATHS'] = frameworks_paths.join(" ")
File.open(xcconfig_path, "w") { |file| file << "" }
build_settings.each do |key,value|
File.open(xcconfig_path, "a") {|file| file << "#{key} = #{value.strip}\n"}
end
listPaths.each do |frameworks_path|
print_info "[#{target.name}] Add frameworks #{File.basename frameworks_path}"
new_file_framework = config.project.frameworks_group.new_file(frameworks_path)
target.frameworks_build_phase.add_file_reference(new_file_framework, true)
end
end
end
end
end
Podfile [Run Fuction]
post_install do |installer|
inject_frameworks(installer, "#LIB_ERROR#", [
'$(PROJECT_DIR)/Google-Mobile-Ads-SDK/Frameworks/frameworks/GoogleMobileAds.framework',
'$(PROJECT_DIR)/GoogleAds-IMA-iOS-SDK/GoogleInteractiveMediaAds/GoogleInteractiveMediaAds.framework'
])
end
Here is the answer:
Import this into your .m file:
#import <GoogleMobileAds/GADInterstitial.h>
#import <GoogleMobileAds/GADBannerView.h>