Google Analytics iOS and Alamofire and cocoapods - ios

I have been working with google analytics fine for the past year and now I am switching to swift. I have a problem importing it using the pods [ I have done an extensive search and it seems a problem with [use_frameworks!] that is required by Alamofire.
I have added the SDK manually, that is libGoogleAnalyticsServices.a
and imported some other files in a bridging file called header-Bridging-Header.h:
#import <Google/Analytics.h>
#import <libGoogleAnalyticsServices.a>
#import "GAI.h"
#import "GAIDictionaryBuilder.h"
#import "GAIEcommerceFields.h"
#import "GAIEcommerceProduct.h"
#import "GAIEcommerceProductAction.h"
#import "GAIEcommercePromotion.h"
#import "GAIFields.h"
#import "GAILogger.h"
#import "GAITrackedViewController.h"
#import "GAITracker.h"
now in AppDelegate.swift I am trying to configure tracker from GoogleService-Info.plist.
var configureError:NSError?
GGLContext.sharedInstance().configureWithError(&configureError)
if configureError != nil {
println("Error configuring the Google context: \(configureError)")
}
but it shows an error used of unresolved identifier GGLContext

Google was a bit slow to properly support Cocopods but this has been resolved, now. The tricky bit now is to know which version of Google Analytics pod to use as there are at least three different ones, two of which are authored by Google themselves. For using GA using CocoaPods most likely you should be using the one they officially recommend using, which is listed here:
https://developers.google.com/analytics/devguides/collection/ios/v3/?ver=swift
as of this writing the pod is pod 'Google/Analytics' - using this GA should work without additional effort and without directly embedding any libraries into your code. Additionally the only thing you need in you bridging header is this:
#import <Google/Analytics.h>
For a detailed explanation of why there are so may different pods and which one to use, see this video:
https://www.youtube.com/watch?v=JQJd7qyWh5k

into your cocoapods you need to set:
pod 'Google/Analytics'
If you want to use:
var configureError:NSError?
GGLContext.sharedInstance().configureWithError(&configureError)
if configureError != nil {
println("Error configuring the Google context: \(configureError)")
}
If you use:
pod 'GoogleAnalytics' #(without '/')
GGLContext will not be available :)..

Related

GoogleAnalytics Cocoapod unresolved identifier 'GGLContext'

With the Google cocoapod now deprecated I have switched to using the GoogleAnalytics pod and amended my bridging header to import the following:
#import "GAI.h"
#import "GAIDictionaryBuilder.h"
#import "GAIEcommerceFields.h"
#import "GAIEcommerceProduct.h"
#import "GAIEcommerceProductAction.h"
#import "GAIEcommercePromotion.h"
#import "GAIFields.h"
#import "GAILogger.h"
#import "GAITrackedViewController.h"
#import "GAITracker.h"
Now my build keeps failing at:
GGLContext.sharedInstance().configureWithError(&configureError)
Can't find anything in the Google docs and Google searches have also proved fruitless.
A point in the right direction would be greatly appreciated, or even pointing out something painfully obvious that I'm missing.
This answer was the correct one, not the one marked as "correct" since it suggests to use deprecated version of libraries instead of moving on with the new versions and updating your project accordingly:
https://stackoverflow.com/a/46858690/3506788
If you use Firebase, make sure that you initialise Firebase before using this line:
GIDSignIn.sharedInstance().clientID = FirebaseApp.app()?.options.clientID

Failed to import bridging header facebook sdk

Hello guys I got this error when attempting to compile my file in swift:
I have added the frameworks: FSBDKCoreKit, FBSDKLoginKit, FBSDKShareKit, and Bolt to my root folder and not my xcodeprojectworkspace. But I'm receiving these errors. Please I need some assistance.
Also i added the frameworks in DealsApp-Bridging-Header:
I had the same problem some days ago. Couldn't find why but when I tried to install the sdk with cocoa pods instead of just dragging the files it just worked.
Give this a try: https://edbinx.com/apple/ios/use-facebook-fbsdk-swift-cocoapods-ios-9-13369.html
From Errors, I think you need to add
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <FBSDKLoginKit/FBSDKLoginKit.h>
in your file "DealsApp-Bridging-Header.h"

Swift + Objective C Venmo Pod: 'VENUser.h' file not found

I'm trying to integrate this in a Swift application. I'm using Xcode 6.4 and CocoaPods 0.38.2.
My podfile looks like this:
platform :ios, '8.0'
use_frameworks!
target 'my_app_name' do
pod 'Venmo-iOS-SDK', '~>1.3'
end
With no import in my bridge header, the app runs. With #import <Venmo_iOS_SDK/Venmo.h> however, I get the following error:
..Pods/Venmo-iOS-SDK/venmo-sdk/Categories/VENUser+VenmoSDK.h:1:9: 'VENUser.h' file not found
.../my_app_name-Bridging-Header.h:6:9: Could not build module 'Venmo_iOS_SDK'
Failed to import bridging header '../my_app_name/my_app_name-Bridging-Header.h'
The lines at the top of the Venmo.h file are as follows
#import Foundation;
#import UIKit;
#import <VENCore/VENCore.h>
#import "VENErrors.h"
#import "VENPermissionConstants.h"
#import "VENSession.h"
#import "VENTransaction+VenmoSDK.h"
I tried adding another pod just to make sure it was an issue specifically with my integration with venmo-ios-sdk and ended up adding #import <VENCore/VENcore.h> with zero problems. I'm pretty new to iOS, so I don't really know if I'm missing something extra obvious...
You shouldn't be importing the framework within your bridge header, but instead importing it directly in your Swift code using Swift imports:
import Venmo_iOS_SDK
Alternatively if you are using the Pod from Objective-C, you should be importing the framework header:
#import <Venmo_iOS_SDK/Venmo_iOS_SDK.h>
Or, using module imports in Objective-C (http://tonyarnold.com/2014/04/10/clean-up-your-projects-with-xcode-5.html):
#import Venmo_iOS_SDK;
I don't know if there was another way to solve this, but I just edited the pod so in VEnUser+VenmoSDK.h the first line was changed to
#import "VENCore/VENUser.h"
instead of
#import "VENUser.h"
I was looking at the wrong file so didn't see the "obvious" error, nor was it particularly obvious to me...but this fixes it.
You can check Header search paths or Library search paths.
Also can pod install.

iOs: Swift Google Analytics

I am new to iOs development and would like to implement Google Analytics (swift).
It appears there is some missing information on implementing Google Analytics in swift on Google's instruction page:
It seems the import statement above is incorrect, can anyone assist me with the missing/correct statement?
Exta Info:
I come from a Java background and IDEs I use import for you, so
please excuse my stupidity.
I have cocopods installed, and use other pods: Almofire, Fabric, swiftyJson etc
I am developing for iOs 8
Instructions above this, are clear and working. Installing the pods/config file etc
In your Objective-C bridging header file, You should import GA header files:
#import "GAI.h"
#import "GAIDictionaryBuilder.h"
#import "GAIEcommerceFields.h"
#import "GAIEcommerceProduct.h"
#import "GAIEcommerceProductAction.h"
#import "GAIEcommercePromotion.h"
#import "GAIFields.h"
#import "GAILogger.h"
#import "GAITrackedViewController.h"
#import "GAITracker.h"
I am not sure if I am missing some import.
If you look in your Pods folder in Xcode you can see the available pods there. Most of them usually have a file that contains all import statements for any files needed. In this case its the Analytics.h file in Pods/Google/Analytics/
I'm guessing that, to import this file in your bridging header (which I hope you have, if not let me know), you can use #import "Google/Analytics.h".
It also says a little bit lower on the page, to import the <Google/Analytics.h> to the header.

PFFacebookUtils.h (1.7.1) imports non-existent FacebookSDK.h

I've installed the Parse and Facebook iOS SDKs for my project in Xcode. My project is written in Swift so I have the following in my bridging header:
#import <Parse/Parse.h>
#import <ParseUI/ParseUI.h>
#import <ParseCrashReporting/ParseCrashReporting.h>
#import <Intercom/Intercom.h>
#import <ParseFacebookUtils/PFFacebookUtils.h>
When I build the app, I get 2 errors:
error: 'FacebookSDK/FacebookSDK.h' file not found
error: failed to import bridging header '/Users/ben/AppFolder/MyApp/Bridging-Header.h'
The bridging header is at the directory as shown, so it seems that is dependent on the first error. FacebookSDK.h is in an #import statement at the top of PFFacebookUtils.h:
#import <Foundation/Foundation.h>
#import <FacebookSDK/FacebookSDK.h>
#import <Parse/PFConstants.h>
#import <Parse/PFNullability.h>
#import <Parse/PFUser.h>
FacebookSDK.h does not exist in either the Parse iOS SDK 1.7.1 or the Facebook SDK (presumably 4.0.1) from Facebook's Getting Started page, though I know that FacebookSDK.h was in previous versions.
I tried the approved answer from this SO question without success. Do I need to add something to my bridging header? Should I change the import statement for FacebookSDK.h to reference a different file? Other ideas on how to fix this?
Instead of
#import <ParseFacebookUtils/PFFacebookUtils.h>
use :
#import <ParseFacebookUtilsV4/PFFacebookUtils.h>
Make sure to add that V4

Resources