Mattias Farnemyhr
Mattias Farnemyhr

Reputation: 4238

Getting GoogleAnalytics CocoaPod to work in a Swift project

I have a Swift project and have included some Swift CocoaPods to it and it works well. However, now I want to add the GoogleAnalytics pod which doesn't have a Swift version but only support Objective-C, this is how my Podfile looks like:

source 'https://github.com/CocoaPods/Specs.git'                                  
platform :ios, '8.0'                                                             
use_frameworks!                                                                  

target 'MyApp' do                                                             
  pod 'MEViewExtensions', '~> 0.2'                                               
  pod 'SwiftColors', '~> 0.2'                                                    
  pod 'GradientView', '~> 2.0'                                                   
  pod 'GoogleAnalytics', '~> 3.12'                                               
end

After installing the pods, GoogleAnalytics does not get it's own framework in the Pods project like the others. I've tried to import it though like a framework, like this:

import GoogleAnalytics

It doesn't work. I've also tried a bridging header like this:

#ifndef MyApp_Bridging_Header_h
#define MyApp_Bridging_Header_h

#import <GoogleAnalytics/GAI.h>

#endif

It doesn't work either. Can anybody help?

Upvotes: 3

Views: 885

Answers (1)

Mattias Farnemyhr
Mattias Farnemyhr

Reputation: 4238

There now exists a Swift version of Google Analytics. I've used it in a couple of projects:

pod 'Google/Analytics', '~> 1.3'

Upvotes: 4

Related Questions