我一直在尝试按照其网站上的教程,将Objective C Chartboost SDK集成到Swift项目中,并通过使用桥接标头等使其适应我所知的Swift。不幸的是,当我运行初始AppDelegate代码时,我得到了很多如以下屏幕截图所示的错误
图片链接:
然后我尝试在@Objective C之类的字符串之前加上@符号,这也带来了很多错误,经过一番研究之后,我仍然没有真正找到解决此问题的方法,但是这些是我遇到的错误尝试以以下方式添加@符号。
Chartboost.startWithAppId(appId:@"appID", appSignature:@"appSig", delegate: self)
图片链接:
我还尝试了以下操作,并遇到了另一个类似的错误:
let kChartboostAppID: NSString = "123"
let kChartboostAppSignature: NSString = "123"
Chartboost.startWithAppId(appId:kChartboostAppID, appSignature:kChartboostAppSignature, delegate: self)
但这给了我以下错误(类似于第一个错误):
无法将表达式的类型'(appId:NSString,appSignature:NSString,委托:AppDelegate)'转换为'(String !, appSignature:String !,委托:ChartboostDelegate!)->无效'
我很感谢您的协助,因为我一直在努力解决这一问题:)
这对我有用...
将框架放入支持文件
添加到桥接头
#import <UIKit/UIKit.h>
#import <Chartboost/Chartboost.h>
将chartboost委托添加到appdelegate.swift
class AppDelegate: UIResponder, UIApplicationDelegate, ChartboostDelegate {
在正式的发布会上
let kChartboostAppID = "appid"
let kChartboostAppSignature = "appsignature"
Chartboost.startWithAppId(kChartboostAppID, appSignature: kChartboostAppSignature, delegate: self)
Chartboost.setShouldRequestInterstitialsInFirstSession(false)
显示广告
Chartboost.showInterstitial(CBLocationHomeScreen)
Chartboost.showInterstitial("AnyCusotmTitleID")
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句