如何使用swift语言在ios中集成flurry [英] how to integrate flurry in ios using swift language

查看:93
本文介绍了如何使用swift语言在ios中集成flurry的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用swift语言在ios中集成flurry。
我添加了flurry sdk的两个文件:flurrylib.a和flurry.h然后在项目TestProject4-Bridging-Header.h中输入我的api密钥

I want to integrate flurry in ios using swift language. I added the flurry sdk's two files : flurrylib.a and flurry.h and then entered my api key in project TestProject4-Bridging-Header.h

#import "Flurry.h"


推荐答案

我遇到了同样的问题,并为我添加了一个桥接头。以下是我遵循的步骤。

I had the same issue and adding a bridging header worked for me. Here are the steps I followed.

注意:如果您已经有桥接文件,请跳过步骤2到4

Note: If you already have a bridging file, skip the steps 2 to 4


  1. 我将Flurry文件夹拖到我在XCode中的Swift iOS项目。

  2. 我通过创建一个新的Objective-C头文件创建了一个桥接头文件(在XCode菜单中,它是文件/新建/文件/ iOS /源/头文件)

  3. 我调用了文件名PROJECTNAME-Bridging-Header.h(用您的XCode项目名称替换PROJECTNAME) )

  4. 在项目构建设置中,我搜索了Swift编译 - 代码生成,并在Objective-C Bridging Header中输入了我的新桥接文件的名称(PROJECTNAME-Bridging) -Header.h)用于调试和释放值。

  5. 现在,回到我的桥接头文件中,我引用了Flurry头文件。

  1. I dragged the Flurry folder to my Swift iOS project in XCode.
  2. I created a bridging header file by creating a new Objective-C header file (in XCode menu it's File/New/File/iOS/Source/Header File)
  3. I called the file name "PROJECTNAME-Bridging-Header.h" (replace PROJECTNAME with your XCode project name)
  4. In Project Build Settings, I searched for "Swift Compile - Code Generation" and there in "Objective-C Bridging Header" I entered the name of my new bridging file (PROJECTNAME-Bridging-Header.h) for debug and release values.
  5. Now, back in my bridging header file, I referenced the Flurry header file.

#importFlurry.h

在我的AppDelegate.swift文件中,我可以使用Swift调用Flurry方法:

In my AppDelegate.swift file, I could then call the Flurry methods using Swift:

func application(application:UIApplication,didFinishLaunchingWithOptions launchOptions :[NSObject:AnyObject]?) - > Bool {
//设置Flurry
Flurry.startSession(flurryKey)//用自己的密钥替换flurryKey
Flurry.setCrashReportingEnabled(true)//在Flurry中记录应用程序崩溃
Flurry .logEvent(启动应用程序)//偶数记录示例

希望它帮助某人。

这篇关于如何使用swift语言在ios中集成flurry的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆