Search code examples
objective-cswiftchartboost

How to integrate Chartboost IOS SDK with Swift


I am trying to integrate the Chartboost IOS SDK with Swift. I have followed all the instructions on the Chartboost IOS Integration page https://answers.chartboost.com/hc/en-us/articles/201220095-iOS-Integration and have created a bridging header to use the framework in my swift project.

BridgingHeader.h

#import <Chartboost/Chartboost.h>
#import <Chartboost/CBNewsfeed.h>
#import <CommonCrypto/CommonDigest.h>
#import <AdSupport/AdSupport.h>

My BridgingHeader.h file is loacated in my project root directory https://i.sstatic.net/tl6kY.png and I have followed the necessary steps to add the BridgingHeader.h to my Build Settings https://i.sstatic.net/kM4Tq.png but when I run the project I get 52 errors like -> https://i.sstatic.net/RZjRI.png. Why am I getting these errors and how do I get rid of them?


Solution

  • It looks like the headers require UIKit and Foundation. Add this line at the top of your bridging header.

    #import <UIKit/UIKit.h>
    

    Also, have you made sure your bridging header is in the project's root in the file system? The hierarchy of Xcode's Project Navigator isn't necessarily the same as the file system.

    It's looking for the header in /Users/andrew/Documents/dev/ios/Protect Paigridge/ Open finder and make sure that the header is in that directory. Xcode may have created it a level deeper where the rest of your code files are. If that's the case, you can edit entry in Build Settings or move the file.