Salvo96
Salvo96

Reputation: 11

Admob Conversion Tracking in Swift

I tried to set conversion tracking in my iOS game, but I didn't be able to do that. The tutorial can be found here: https://developers.google.com/app-conversion-tracking/ios/?hl=it#usage_and_disclosure

I integrate the GoogleConversionTrackingSDK to my project, load AdSupport framework and type -ObjC in Other linker flags. I tried to convert this snippet from Obj-C:

[ACTConversionReporter reportWithConversionID:@"MY_ID" label:@"MY_LABEL" value:@"MY_VALUE" isRepeatable:NO];

to Swift:

ACTConversionReporter.reportWithConversionID("MY_ID", label: "MY_LABEL", value: "MY_VALUE", isRepeatable: false)

and I put that in didFinishLaunchingWithOptions method of AppDelegate.swift, but I get the error:

Use of unresolved identifier 'ACTConversionReporter'

If I type in Obj-C bridging header in Swift Compiler - Code Generation in Build Settings "ACTReporter.h" (without qm), I put the header file in the folder of my game or if I type the whole path of "ACTReporter.h" ending with its name, I fail the build and I get 2 errors:

Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_ACTConversionReporter", referenced from: type metadata accessor for __ObjC.ACTConversionReporter in AppDelegate.o

ld: symbol(s) not found for architecture armv7 clang: error: linker command failed with exit code 1 (use -v to see invocation)

I don't know what to do. I hope there is someone who can fix this.

Upvotes: 1

Views: 801

Answers (1)

student swift
student swift

Reputation: 29

You need to add to your project "YourProjectName-Bridging-Header.h" file

Here you can see how to add the file

in Bridging Header file add #import "ACTReporter.h"

Then it will work for you!

Upvotes: 1

Related Questions