0

I have been working on a Swift/iOS game. I am currently implementing the ads for it and am using the Amazon ads library. I have added it to my project. The sample code given on the quick starter guide is in Objective-C but that isn't too much of an issue. I created the bridge.h file and linked it in the Objective-C Bridging Header.

My bridge file is:

#ifndef Bridge_H
#define Bridge_H
import <AmazonAd/AmazonAdRegistration.h>
import <AmazonAd/AmazonAdOptions.h>
import <AmazonAd/AmazonAdError.h>
import <AmazonAd/AmazonAdInterstitual.h>
#endif

I noticed in the quick guide that the AmazonAd/AmazonAdInterstitual.h file wasn't located in the same location as the other 3 files. But I don't think that would be much of an issue, or is it? Anyways, that last one, AmazonAd/AmazonAdInterstitual.h is the one causing problems. When I try to compile and build I get an error linking to a method in that header:

// Present an interstitial on screen
- (void)presentFromViewController:(UIViewController *)viewController;

And the error states "Expected a Type" Followed by another error stating that it "Failed to import bridging header: "

If I go into that header file, the Amazon Interstitual one, and comment out that specific line, and then compile and build, it does so without issue. The problem is that that specific method call is the call needed to display the ad on screen. Without it I cannot display ads and get impressions.

Is this an issue with the header file? Or could it be an error somewhere else causing it to display these errors?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Zero
  • 67
  • 10
  • I think `AmazonAd/AmazonAdInterstitual.h` missing would be an issue, try changing the bridging header path to reflect that. – Phil Hudson Aug 19 '16 at 02:20
  • Not having that header file would be an issue as it is required to display the ads. But including it is what causes the problems. But I found a solution. I just had to add @class UIViewController to the top of AmazonAd/AmazonAdIntersitual.h – Zero Aug 19 '16 at 04:38

1 Answers1

1

So I found out the solution. Expected a type error Actually had a similar issue. The problem is that the class isn't seeing the type being passed to it as it hasn't been defined yet. Simply adding @class UIViewController; to the top of the Amazon/AmazonAdInterstitual.h file fixed the issue. Not sure if it is just a swift to objective c issue, or an issue that is in the Amazon Ads sdk as a whole.

Community
  • 1
  • 1
Zero
  • 67
  • 10