Admob import file issue in Objective C - ios

I'm integrating admob to my application. I have followed a tutorial from youtube, followed the respective steps but when I tried to run the app it shows me an error message that GoogleMobileAds/GADAdSize.h' file not found
I have searched about the error and tried many answers from stack overflow but didn't worked. I have added all the classes and GoogleMobileAds.framework also but this error isn't removing , i'm confused that what the thing i'm missing in this? I have added all the classes from the zip File given in Google Mobile Ads SDK for iOS but still not working how I can resolve this? This is my code for admob,
#import "GADBannerView.h"
GADBannerView *bannerView_;
//Admob Banner
bannerView_ = [[GADBannerView alloc]initWithFrame:CGRectMake(0, 20, 320, 50)];
bannerView_.adUnitID = #"ad unit key";
bannerView_.rootViewController = self;
[self.view addSubview:bannerView_];
[bannerView_ loadRequest:[GADRequest request]];
Now in this import file its showing me this error:

Related

Firebase/Admob installation guide with pods on Cocoapods site vs Firebase installation guide on google

I'm trying to integrate firebase/admob ads for ios app using Cocoapods.
On Cocaopods site there is a guide such as downloading Cocoapods first then creating a pod file in the app and adding a code using pods. On Google site there are also instructions on how to install firebase ads sdk using pods but then it seems that I also need to insert coding such as gad etc in the actual application. I'm new to this, so I'm a bit confused - is Cocoapods coding enough or do I also need to add coding in the application as well in terms of initializing ads or creating buttons for specific ads such as banner/interstitial etc?
You have to add some coding in the app as well such that importing the Googlemobileads in the app delegate and configuring it in the func didFinishLaunchingWithOptions:
GADMobileAds.configure(withApplicationID: "Your application id")
and then adding the below code in your first controller or the controller in which you want to show the adds:
var bannerView: GADBannerView!
bannerView = GADBannerView(adSize: kGADAdSizeSmartBannerPortrait)
bannerView.frame.origin.y = self.view.frame.size.height - bannerView.frame.size.height
self.view.addSubview(bannerView)
bannerView.adUnitID = "Your ad unit id"
bannerView.rootViewController = self
bannerView.load(GADRequest())
Also, I think the code is in C that's why I had problems with it and not Swift. I've managed to get almost everything done - I have a problem when I use self.bannerView and also GADBannerView with messages that it hasn't been declared previously. I tried to follow Objective C because that's how the code looks like, but don't seem to be able to resolve this.

iOS google places API - compile error - use of undeclared identifier GMSAutocompleteViewController

I have installed GoogleMaps SDK using CocoaPods.
For some screen I need to use Google Places API
Here is the code
GMSAutocompleteViewController *acController = [[GMSAutocompleteViewController alloc] init];
acController.delegate = self;
[self presentViewController:acController animated:YES completion:nil];
Which I have got from https://developers.google.com/places/ios-api/autocomplete
The error - use of undeclared identifier 'GMSAutocompleteViewController'
Have you added #import <GoogleMaps/GoogleMaps.h> to the file?
The other possibility is that you have an older version of the GoogleMaps pod (GMSAutocompleteViewController was added in version 1.11). To fix this, just run
pod update
in the project directory.

Facebook iOS SDK 4.0.1 "You must upgrade this app to Graph API v2.x"

I am trying to upgrade a facebook app from using the soon-to-be-deprecated 1.0 API to the current one. I have replaced the frameworks (FBSDKCoreKit, FBSDKLoginKit) with the current ones (4.0.1). Doing this upgrades the app when I log in using the web-fallback. However, when I log in through the facebook app I still get the deprecation warning. This is my (abstracted) code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSLog(#"SDK version: %#", [FBSDKSettings sdkVersion]); // Prints "SDK version: 4.0.1
UIViewController *vc = [UIViewController new];
FBSDKLoginButton *loginButton = [FBSDKLoginButton new];
loginButton.frame = CGRectMake(10, 200, 300, 50);
[vc.view addSubview:loginButton];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = vc;
[self.window makeKeyAndVisible];
return YES;
}
When logging in, I see the following warning message:
"You must upgrade this app to Graph API v2.x"
I am aware of these two questions:
Facebook iOS SDK: Why am I getting "You must upgrade this app to Graph API v2.x"?
iOS - Facebook - You must upgrade this app to Graph API v2.x
None of them solves my problem though.
The problem is not that I am using an old SDK-version. I have verified that the files on disk and in the project are the ones downloaded from the 4.0.1 SDK, which I also verify by printing the SDK-version. I have tried deleting and re-adding them several times.
The problem is not the code. My code does basically nothing, just calls the built in login-code for fb.
This is the iOS SDK, so I do not specify the urls for the API-calls myself. The official documentation states that using the most recent SDK should ensure that the correct urls are used.
So the problem is either in some project setting, but they don't seem to specify api-version, or in the facebook app itself, where I cannot find it. Any help is appreciated.
Same story here.
Purge the entire DerivedData (/Users/.../Library/Developer/Xcode/DerivedData) folder.
It helped 4

Google Admob Integration Error in iOS

Google Admob Integration Error in iOS
I am using GoogleMobileAdsSdkiOS-6.12.2 latest version downloaded from https://developers.google.com/mobile-ads-sdk/download.
If I run on iOS 7.x, I am getting the following errors.
1) CFNetwork SSLHandshake failed (-108)
2) NSURLConnection/CFURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -108)
If I run on iOS 8.x, I am getting Crash due to "com.apple.nsurlconnectionloader exc_bad_access" error.
Added below code for integrate Google Admob.
GADBannerView *bannerView = [[GADBannerView alloc]initWithFrame:CGRectMake(0.0,self.view.frame.size.height -GAD_SIZE_320x50.height,GAD_SIZE_320x50.width,GAD_SIZE_320x50.height)];//Set Position
bannerView.adUnitID = #"ca-app-pub-3940256099942544/2934735716";
bannerView.rootViewController = self;
GADRequest *request = [GADRequest request];
request.testDevices = #[ GAD_SIMULATOR_ID, #"MY_TEST_DEVICE_ID" ];
[bannerView loadRequest:request];
Anyone please help me to get out of this issue.
In my case, It is because of the Network blocker issue.
If I run this code in my office, I am getting these type of errors.
If I run same on my home, It is working fine.
Because in my office they are blocking adds.
So I asked my N/W admin to allow adds on my system, He allowed, My issue resolved.
It is a network not getting error.Please check any blocking or Proxy.

Admob Interstitial exception

I have 2 apps with Admob Interstitials.
Admob Interstitial stopped to work in 1 app.
I get exception calling loadRequest method.
Exception: -[__NSCFDictionary setObject:forKey:]: attempt to insert nil key
interestial = [[GADInterstitial alloc] init];
interestial.adUnitID = PUBID;
//interestial.delegate = interestialDelegate;
GADRequest *request = [GADRequest request];
[interestial loadRequest:request];
I made many many I spent day morfing code. Also I have same working code in another app.
May be it is something in project like missing framework or else
I tried Admob 6.3.0, 6.2.1, 6.1.5
Major change to my Admob code was upgrade to 6.3.0 but second app was also upgraded.
I am logging PUBID. It is not nil.
I do not pass NSDictionary to Admob my self.
The difference between apps is that it works in app with ARC and fails in non ARC app.
The most common problem is -ObjC flag in Other Linker Flags

Resources