I've an iOS app which has a framework in it. Framework is being used in main app. Both main app and framework need to use Google-Mobile-Ads-SDK
for loading ads.
Here is podfile:
platform :ios, '10.0'
target 'MyFramework' do
use_frameworks!
pod 'FLAnimatedImage', '~> 1.0'
pod 'Google-Mobile-Ads-SDK', '~> 7.67.0'
...
end
target 'MainApp' do
use_frameworks!
pod 'CocoaLumberjack/Swift', '~> 3.5.3'
pod 'Google-Mobile-Ads-SDK', '~> 7.67.0'
...
end
This is how I'm requesting ads, from both main app and framework:
let videoOptions = GADVideoOptions()
var adOptions = [GADAdLoaderOptions]()
adOptions.append(videoOptions)
let adLoader = GADAdLoader(adUnitID: "ad id",
rootViewController: nil,
adTypes: adTypes,
options: adOptions)
adLoader.delegate = self
let dfpRequest = DFPRequest()
dfpRequest.contentURL = "some url"
adLoader.load(dfpRequest)
Main app is requesting ads before framework does.
This code works perfectly fine in framework but gives below error in main app:
Domain=com.google.admob Code=2 "SDK tried to perform a networking task before being initialized." UserInfo={NSLocalizedDescription=SDK tried to perform a networking task before being initialized.,
gad_response_info= ** Response Info ** Response ID: (null) Network: (null)
** Mediation line items **
If I remove Google-Mobile-Ads-SDK
from framework pods then main app works perfectly.
What can be wrong in this?
Somehow I feel like this is related to cocoapods but not sure... I have tried lots of ways by modifying podfile (but not worked) like:
Try-1
target 'MyFramework' do
use_frameworks!
pod 'FLAnimatedImage', '~> 1.0'
pod 'Google-Mobile-Ads-SDK', '~> 7.67.0'
target 'MainApp' do
inherit! :complete
pod 'CocoaLumberjack/Swift', '~> 3.5.3'
end
end
Try-2
def ad_pods
pod 'Google-Mobile-Ads-SDK', '~> 7.67.0'
end
target 'MyFramework' do
use_frameworks!
pod 'FLAnimatedImage', '~> 1.0'
ad_pods
end
target 'MainApp' do
use_frameworks!
pod 'CocoaLumberjack/Swift', '~> 3.5.3'
ad_pods
end
and lot of other ways.