【问题标题】:Chartboost SDK Swift IntegrationChartboost SDK Swift 集成
【发布时间】:2014-12-21 11:12:50
【问题描述】:

我一直在尝试将 Objective C Chartboost SDK 集成到 Swift 项目中,方法是按照他们网站上的教程进行操作,并通过使用桥接头等方式将其调整为 swift。不幸的是,当我运行初始 AppDelegate 代码时,我得到了如下截图所示的一些错误

图片链接:

https://imgur.com/wO5eyem

然后我尝试像在 Objective C 中那样将 @ 符号放在字符串之前,这也带来了大量错误,经过大量研究后,我仍然没有真正找到解决此问题的方法,但这些是错误当我尝试按以下方式添加 @ 符号时给出。

Chartboost.startWithAppId(appId:@"appID", appSignature:@"appSig", delegate: self)

图片链接:

https://imgur.com/HQqMYEj

我还尝试了以下方法,但遇到了另一个类似的错误:

    let kChartboostAppID: NSString = "123"
    let kChartboostAppSignature: NSString = "123"
    Chartboost.startWithAppId(appId:kChartboostAppID, appSignature:kChartboostAppSignature, delegate: self)

但这给了我以下错误(类似于第一个错误):

无法将表达式的类型“(appId: NSString, appSignature: NSString, delegate: AppDelegate)”转换为类型“(String!, appSignature: String!, delegate: ChartboostDelegate!) -> Void”

我非常感谢任何帮助,因为我已经尝试解决这个问题很长时间了:)

【问题讨论】:

    标签: ios objective-c xcode swift chartboost


    【解决方案1】:

    这对我有用...

    1. 将框架放到支持文件中

    2. 添加到桥接头

      #import <UIKit/UIKit.h>
      #import <Chartboost/Chartboost.h>
      
    3. 将 chartboost 代理添加到 appdelegate.swift

      class AppDelegate: UIResponder, UIApplicationDelegate, ChartboostDelegate {
      
    4. 在 appldelegate 中完成启动

      let kChartboostAppID = "appid"
      let kChartboostAppSignature = "appsignature"
      Chartboost.startWithAppId(kChartboostAppID, appSignature: kChartboostAppSignature, delegate: self)
      Chartboost.setShouldRequestInterstitialsInFirstSession(false)
      
    5. 显示广告

      Chartboost.showInterstitial(CBLocationHomeScreen)
      Chartboost.showInterstitial("AnyCusotmTitleID")
      

    【讨论】:

      猜你喜欢
      • 2023-03-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多