GoogleAnalytics Cocoapod unresolved identifier 'GGLContext' - ios

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

Related

Google Analytics iOS and Alamofire and cocoapods

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 :)..

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

AFNetworking Clang Error with Exit code 254 - Xcode 4.6.2

I am trying to use AFNetworking with Xcode 4.6.2 in my projects. I have added the AFNetworking to my project. I have also added 'SystemConfiguration' and 'MobileCoreServices' framework to the project. I have included the framework header files in the .pch file like below
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
#import "AFNetworking.h"
#import <SystemConfiguration/SystemConfiguration.h>
#import <MobileCoreServices/MobileCoreServices.h>
When I try to run the project, I get Clang error from file AFHTTPClient as follows
Command/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 254
Ok , I solved the problem. The issue was with order of import statements in .pch file
I changed the order to as follows basically added 'AFNetworking.h' after import statements for and frameworks.
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
#import <SystemConfiguration/SystemConfiguration.h>
#import <MobileCoreServices/MobileCoreServices.h>
#import "AFNetworking.h"
Also another tip. You also need to add 'Security' framework for AFNetworking to work smoothly. Thanks

Failing to import c-file in objective-c

I'm currently trying to compile my project just after adding some C code.
I'm using the Paul Kocher's blowfish algorithm implementation available on Bruce Schneier's website.
Since I included blowfish.c & blowfish.h in my workspace, my compiler is running crazy. Like if it did not recognize Objective-c code, pointing errors on NSObject class!
I tried to .mm the calling class but the problem stays.
Each answer found on SO talks about including C++ file, but it's not my pb...
Maybe a compiler directive that i'v missed ?
Most likely, what is happening is that the compilation of blowfish.c is using your previously established precompiled header (.pch) file, and that is including an Objective-C framework. Just disable the precompiled header and you should be OK. You might be able to conditionalize those frameworks, but personally, I find precompiled headers more trouble than they’re worth.
Thanks to microtherion, I found the problem.
My .pch file was declared as :
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif
#import "AppDelegate.h"
#import "UINavigationController+Rotation.h"
#import "Categories.h"
The 3 last #import'ed files are objective-C.
I've just changed the #endif place to:
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "AppDelegate.h"
#import "UINavigationController+Rotation.h"
#import "Categories.h"
#endif

Resources