0

I am having a problem with the Google Analytics library, I successfully added the library using cocoapods and it works fine when I run the application however, when I run unit tests the file GAITrackedViewController.h is not found. The compiler highlights the error as a lexical or Preprocessor issue.

I have retried to reinstall the library a couple of times, I have even looked at these threads and more google analytics not found and GAITrackedViewController.h not found and still I can't seem to get a solution to this problem.

I am using Objective-C and Xcode version 8.3.2

rmaddy
  • 314,917
  • 42
  • 532
  • 579
DvixExtract
  • 1,275
  • 15
  • 25

2 Answers2

0

You can look at Firebase Analytics. It is better than GA.

Cocoapod: pod 'Firebase/Core'

AppDelegate:

@import Firebase;

didFinishLaunchingWithOptions:

[FIRApp configure];

UIViewController

[FIRAnalytics logEventWithName:kFIREventSelectContent
                        parameters:@{
                                     kFIRParameterItemID:[NSString stringWithFormat:@"id-HVC"],
                                     kFIRParameterItemName:@"Events",
                                     kFIRParameterContentType:@"screen"
                                     }];

Do not forget add cocoapod this code: source 'https://github.com/CocoaPods/Specs.git'

erim kurt
  • 91
  • 6
  • Thank you ErimKurt for the suggestion however I am supporting a code base that was written using google analytics and changing to firebase analytics, will be a last option. I appreciate your suggestion thank you. – DvixExtract Aug 18 '17 at 13:12
0

I solved the problem and decided to post the answer incase someone runs into this problem one day.

The problem is caused by cocoapods headers not linking to test targets thus to fix the issue I had to add a separate target definition in my podfile.

I added the targets as follows:

target ‘Project NameTests' do
       inherit! :search_paths
project 'Project Name.xcodeproj'

end

target 'Project NameUITests' do
        inherit! :search_paths
project 'Project Name.xcodeproj'

end

DvixExtract
  • 1,275
  • 15
  • 25