iOS: Wrong instruction in installing Google Mobile Ads SDK? - ios

I'm following this tutorial to put Google Ad on my page: https://firebase.google.com/docs/admob/ios/quick-start
At the step:
GADMobileAds.configureWithApplicationID("ca-app-pub-8123415297019784~8909888406");
And the error occurred:
AppDelegate.swift:58:9: Type 'GADMobileAds' has no member 'configureWithApplicationID'
And after the checking, i see there is no member configureWithApplicationID.
What's wrong with this instruction?
And why i have to install Firebase/Core in this version?
Here are methods in GADMobileAds, there is no configureWithApplicationID like Objective C version. How stupid is that http://i.imgur.com/Od0vkPg.png

Remove the cocoapods line from the instruction and replace with this line:
pod 'Google-Mobile-Ads-SDK'
It will install the google sdk version 7.9.0 and you'll see the configureWithApplicationID method. This is the error from Google for Swift.

Xcode 7.3, iOS9.3.3
Followed the instructions above, but wanted to expand, in hopes of saving someone time. If you had 'Google-Mobile-Ads-SDK' pod already installed, then check the version to make sure it is 7.9.0+. Otherwise, you will keep installing the old version over and over.
To update the version, follow the instruction taken from Cocoapods website https://cocoapods.org/pods/Google-Mobile-Ads-SDK click "Installation Guide" (bottom right):
The '~> 7.9' bit will force an update.
What I had that did not work:
What it needs to be:
Again, note the version is 7.9.1
The Podfile looks like this:
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
target 'AppName' do
# Uncomment this line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
# Pods for AppName
pod 'Firebase'
pod 'Google-Mobile-Ads-SDK', '~> 7.9'
target 'AppNameTests' do
inherit! :search_paths
# Pods for testing
end
end
Now you will be able to configure GADMobileAds with the Google prescribed method:
[GADMobileAds configureWithApplicationID:#""];
Or the Swift equivalent:
GADMobileAds.configureWithApplicationID("");
Hope this helps! Cheers.

Try to update Podfile to the following:
#pod 'Firebase/AdMob'
pod 'Google-Mobile-Ads-SDK'

I recently tried to update my pod to pod 'Google-Mobile-Ads-SDK', '~> 7.9' and it did not work for me. Because I already had a version of Google-Mobile-Ads-SDK in my file, I simply needed to run pod update. The problem was that Google has updated the SDK beyond 7.9 and updating versus naming a specific version ensures you get the latest one.

The instructions in the Google documentation are ok. I was running into the same issue with CocoaPods installing the old version. Use the Cocoa Pods update command and it fetches the latest version of Admob and the error goes away.

I see it right here in GADMobileAds.h. Check to see if you have the most up to date version.
//
// GADMobileAds.h
// Google Mobile Ads SDK
//
// Copyright 2015 Google Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#interface GADMobileAds : NSObject
/// Returns the shared GADMobileAds instance.
+ (GADMobileAds *)sharedInstance;
/// Configures the SDK using the settings associated with the given application ID.
+ (void)configureWithApplicationID:(NSString *)applicationID;

Related

XmppFramework showing error

I am creating chatting app in Objective-C using XMPPFramework,
I have installed XMPPFramework using pod... pods got installed successfully but when i build my app after install it shows me this error Redefination of module dnssd
I did some research but havn't found any thing related to this.
Here is my pod file:
# Uncomment the next line to define a global platform for your project
platform :ios, ‘8.0’
target 'JabberClient' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
use_frameworks!
pod ‘XMPPFramework’
# Pods for JabberClient
end
Please help me where i am making mistake?
Thanks in advance !!
Try removing/commenting the use_frameworks! line.
It should be used if you're using Swift.

Google AdMob Podfile - Manual vs Auto Version Update?

OK, apologies if this may come across as a 'green' question ...
I have incorporated the Google AdMob SDK via CocoaPods successfully.
My pod file looks like:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '7.0'
pod 'Google-Mobile-Ads-SDK', '~> 7.0'
So my Podfile should automatically 'grab' any version 'newer' than version 7.0.
I am still developing my app, and when I run tests on my physical device, I am presented with this type of message in the console:
You are currently using version 7.8.0 of the SDK. Please
consider updating your SDK to the most recent SDK version to get the
latest features and bug fixes. The latest SDK can be downloaded from
....
So I run Podinstall command via the terminal targeting my relevant directory that holds my development app's latest Xcode project, and it updates all relevant Google Mobile Ad SDKs to the current version.
I guess while my app is not 'live', my Podfile is essentially inactive in terms of updating itself automatically.
Question : If I were to upload my project today to the App Store with my Podfile updated to the most current Google AdMob SDK version, will it automatically update my project to the most current version thereafter? Are the three (3) lines of code in my Podfile sufficient?
Many thanks and apologies in advance if this is an extremely basic question ;)
I am fairly new to CocoaPods myself so I am not 100% what you mean with
"I guess while my app is not 'live', my Podfile is essentially inactive in terms of updating itself automatically."
I believe to update your Pods you need to run the Update command, it does not update itself automatically.
If I were to upload my project today to the App Store with my Podfile updated to the most current Google AdMob SDK version, will it automatically update my project to the most current version thereafter?
I believe no, you need to run podUpdate.
Are the three (3) lines of code in my Podfile sufficient?
Should be
This is how my pod files looks
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
target 'MyGame (iOS)' do
# Comment this line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
pod 'Google-Mobile-Ads-SDK', '~> 7.0'
pod 'ChartboostSDK'
# Pods for MyGame (iOS)
target 'MyGame (iOS) Tests' do
inherit! :search_paths
# Pods for testing
end
end
CocoaPods actually released an app for OSX recently, which makes using it a lot easier
https://cocoapods.org/app
To read more update pod updates vs installs you should read this.
https://guides.cocoapods.org/using/pod-install-vs-update.html
Or a great swift tutorial from ray wenderlich
https://www.raywenderlich.com/97014/use-cocoapods-with-swift
Hope this helps

How to get latest GoogleMaps SDK using pods

I'm trying out the google places sdk sample. I installed it using
pod try GoogleMaps
I installed GoogleMaps (1.10.5) using cocoapods
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.1'
pod 'GoogleMaps'
checking the GoogleMaps in both steps, the one in the sample (1) contains more headers like GMSAutocompleteTableDataSource.h
Why are they different? The one in the sample seems to be a better version but the one given by pods is not the latest? Its not even in the changelog
Run pod update GoogleMaps. Cocoapods won't update the version of a pod you've already downloaded unless you explicitly run pod update or update the podspec to require a newer version. See https://guides.cocoapods.org/using/pod-install-vs-update.html for more details.
I checked the latest podspec
I just need to set the version to the latest
e.g
pod 'GoogleMaps', '~> 2.5.0'
In my project's podfile, I don't specify the version. The pod line just specifies: pod 'GoogleMaps'
So, if you don't include the version in the podfile, then the following command in a Terminal window will update to the latest version: pod 'GoogleMaps'
Please ensure the you are in the correct folder containing your podfile before entering this command.
It may take a while for Pod to process when you see this message: Updating local specs repositories.
Be patient - it took about 20 minutes.
I just ran into this error, and I updated to latest GoogleMaps per the advice above, but had to delete the app on my device and install fresh for it to resolve the error. Error was still present until I did that.

Objective C Project in Xcode 7 CocoaPods Error

The Terminal Error I am receiving after running pod install is:
I realize that ReactiveCocoa's cocoapod is entirely in SWIFT and that I need to Bridge the header files, but my attempts have been far from successful.
I did find this response from one of TeamTreehouse's Staff:
"The SimpleAuth library has it's own set of dependencies one of which is ReactiveCocoa. ReactiveCocoa was recently rewritten completely in Swift so that's the Swift code that's getting added to your project. Unfortunately there are 2 versions of ReactiveCocoa out there, written in Swift 1.2 and Swift 2.0.
SimpleAuth is currently automatically pulling the 1.2 version of ReactiveCocoa.
Swift 1.2 can only be run in Xcode 6.1 and not in Xcode 7 (which requires Swift 2).
So if you are using Xcode 7, then you're pulling in the Swift 1.2 version by default and this is causing all the Swift errors.
Also, you have to do some cleanup work to get Swift frameworks to run in a mixed Objective-C/Swift project which includes adding a bridging header and stuff."
.
^^ Explains my Problem ^^
Thanks in advance!
Edit
After adding use_frameworks! to my Podfile, I was receiving errors like:
The error message says to add the line use_frameworks! to your file called Podfile.
Add it below the first line that should probably say platform :ios, 'x.0'.
You need to use ReactiveCocoa 4.0, which is target Swift 2.0, yet still under alpha version.
If you want to have a try, check this out.
use_frameworks!
target 'YOUR_TARGET' do
pod 'ReactiveCocoa', '~> 4.0.0-alpha'
end
After attempting use_frameworks! within my pod file, I was still experiencing errors due to ReactiveCocoa and the .swift files (even after auto-correcting the errors that Xcode attempted to fix for me).
Within my Podfile I was able to resolve both sets of errors I was experiencing:
1. When including use_frameworks! in the Podfile
2. Also when running my original pod install in hopes of adding the Parse cocoapod
Final code in Podfile
pod 'ReactiveCocoa', '2.4.7'
pod 'SimpleAuth/Instagram', '0.3.6'
pod 'SSKeychain'
pod 'Parse'
You can actually request the latest version of the dependencies. Your Podfile should look like this:
platform :ios, "9.0"
use_frameworks!
target 'MyAppNameHere' do
end
pod 'Box', :head
pod 'Result', :head
pod 'SimpleAuth/Instagram'
Then peform a pod update and in your project, Product > Clean and Product > Build and will work again.

Facebook Cocoapods integration

I am integrating 3rd party libraries into my project using cocoapods. Everything was working smoothly but when i try to integrate facebook ios sdk I encounter a very strange issue, my pods project has the following warning:
If i click on it i get the following dialog:
I checked the Headers in the build phases part of the target "Pods-Facebook-iOS-SDK". Every header file is repeating:
When i try to build my project it fails because it is not able to find "FacebookSDK/FacebookSDK.h".
My last option is to just integrate facebook sdk manually and not use cocoapods for it but I dont want to take that route and for the life of me I cannot understand what I am doing wrong. For refrence following is my pod file:
platform :ios, '7.0'
pod 'DTCoreText'
pod 'UIView+AnimationExtensions'
pod 'EZAudio'
pod 'MZTimerLabel'
pod 'AWSAutoScaling'
pod 'AWSCloudWatch'
pod 'AWSCore'
pod 'AWSDynamoDB'
pod 'AWSEC2'
pod 'AWSElasticLoadBalancing'
pod 'AWSKinesis'
pod 'AWSS3'
pod 'AWSSES'
pod 'AWSSNS'
pod 'AWSSQS'
pod 'AWSSimpleDB'
pod 'Facebook-iOS-SDK'
Following is the information regarding my developement environment:
XCode: 6.1
Architectures: armv7, arm64
Base SDK: iOS 8.1
I was having a similar problem. My project previously had not used Cocoapods and I was now attempting to add the Facebook SDK via Cocapods.
Based on #MingLi's comment, I replaced all instances of #import <FacebookSDK/FacebookSDK.h> with #import <FBSDKCoreKit/FBSDKCoreKit.h> and things started working again.
When I compiled in Xcode, it showed me files that need #import <FBSDKLoginKit/FBSDKLoginKit.h> and #import <FBSDKShareKit/FBSDKShareKit.h>
You will also likely have to go through and adjust things that changed between Facebook SDK 3.x and 4.x. For instance, I had to replace [FBSettings setDefaultAppId:123456789] with [FBSDKSettings appId:123456789] and replace [FBAppEvent activateApp] with [FBSDKAppEvents activateApp].
Xcode is sometimes helpful about finding the needed change, if you compile and then click the red dot (in your code) next to each compile error.
It can take a good bit of work to sort through all of the changes, you may have to recompile many times.
If you are having problems figuring out how to replace specific functions/classes when upgrading from SDK 3.x to 4.x, you can refer to Facebook's Change Log:
https://developers.facebook.com/docs/ios/change-log-4.x
You can also find additional information here:
https://developers.facebook.com/docs/ios/getting-started

Resources