How to integrate Chartboost IOS SDK with Swift

℡╲_俬逩灬. 提交于 2019-12-06 12:12:10

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.

Adding onto the top answer said above try adding both

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <Chartboost/Chartboost.h>

to your BridgingHeader.h File

and make sure they are both above the

#import <Chartboost/Chartboost.h>

as shown above

Swift Chartboost Code, Add it in AppDelegate Class :

func applicationDidBecomeActive(application: UIApplication) 
{        
    let kChartboostAppID = "5472ef8f04b01601a1a5814c";
    let kChartboostAppSignature = "5b6222426e68cda48669a1d4d8246d4c3d20db9c";

    Chartboost.startWithAppId(kChartboostAppID, appSignature: kChartboostAppSignature, delegate: self);
    Chartboost.cacheMoreApps(CBLocationHomeScreen)
}

class func showChartboostAds()
{
     Chartboost.showInterstitial(CBLocationHomeScreen);
}

func didFailToLoadInterstitial(location :String!, withError error: CBLoadError)
{

}

func didDismissInterstitial(location :String! )
{
        if(location == CBLocationHomeScreen)
        {
            Chartboost.cacheInterstitial(CBLocationMainMenu)
        }
        else if(location == CBLocationMainMenu)
        {
            Chartboost.cacheInterstitial(CBLocationGameOver)
        }
        else if(location == CBLocationGameOver)
        {
            Chartboost.cacheInterstitial(CBLocationLevelComplete)
        }
        else if(location == CBLocationLevelComplete)
        {
            Chartboost.cacheInterstitial(CBLocationHomeScreen)
        }
 }

Calling Syntax:

   AppDelegate.showChartboostAds()

This issue is how to import.

You can make objC code and bridge.h, to shows in your code

[Chartboost showInterstitial:CBLocationHomeScreen];

For swift

Chartboost.showInterstitial(CBLocationHomeScreen)

i wish that help you

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!